Skip to content

Commit 83e579d

Browse files
2 parents ed67aa8 + 5e00549 commit 83e579d

File tree

6 files changed

+34
-17
lines changed

6 files changed

+34
-17
lines changed

Changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Not released
22

3+
# Released
4+
35
# 9.31.1
46

57
ElectronNET.CLI:
@@ -33,8 +35,6 @@ ElectronNET.WebApp (internal use):
3335

3436
Thank you for donation [Phil Seeman](https://github.com/mpnow)
3537

36-
# Released
37-
3838
# 8.31.2
3939

4040
ElectronNET.CLI:

ElectronNET.API/HostHook.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ public Task<T> CallAsync<T>(string socketEventName, params dynamic[] arguments)
7272
{
7373
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
7474
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.ToString());
75+
taskCompletionSource.SetException(new Exception($"Host Hook Exception {result}"));
7576
});
7677

7778
BridgeConnector.Socket.On(socketEventName + "Complete" + guid, (result) =>
7879
{
7980
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
8081
BridgeConnector.Socket.Off(socketEventName + "Complete" + guid);
81-
T data;
82+
T data = default;
8283

8384
try
8485
{
@@ -105,7 +106,8 @@ public Task<T> CallAsync<T>(string socketEventName, params dynamic[] arguments)
105106
}
106107
catch (Exception exception)
107108
{
108-
throw new InvalidCastException("Return value does not match with the generic type.", exception);
109+
taskCompletionSource.SetException(exception);
110+
//throw new InvalidCastException("Return value does not match with the generic type.", exception);
109111
}
110112

111113
taskCompletionSource.SetResult(data);

ElectronNET.API/Tray.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ public void Show(string image, MenuItem[] menuItems)
263263
});
264264
}
265265

266+
/// <summary>
267+
/// Shows the Traybar (empty).
268+
/// </summary>
269+
/// <param name="image">The image.</param>
270+
public void Show(string image)
271+
{
272+
BridgeConnector.Socket.Emit("create-tray", image);
273+
}
274+
266275
/// <summary>
267276
/// Destroys the tray icon immediately.
268277
/// </summary>

ElectronNET.CLI/Commands/BuildCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public Task<bool> ExecuteAsync()
186186
ProcessHelper.CmdExecute($"node build-helper.js " + manifestFileName, tempPath);
187187

188188
Console.WriteLine($"Package Electron App for Platform {platformInfo.ElectronPackerPlatform}...");
189-
ProcessHelper.CmdExecute($"npx electron-builder . --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=9.0.3 {electronParams}", tempPath);
189+
ProcessHelper.CmdExecute($"npx electron-builder --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=9.0.3 {electronParams}", tempPath);
190190

191191
Console.WriteLine("... done");
192192

ElectronNET.Host/api/tray.js

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/tray.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ export = (socket: SocketIO.Socket) => {
5353
});
5454

5555
socket.on('create-tray', (image, menuItems) => {
56-
const menu = Menu.buildFromTemplate(menuItems);
57-
58-
addMenuItemClickConnector(menu.items, (id) => {
59-
electronSocket.emit('trayMenuItemClicked', id);
60-
});
61-
6256
const trayIcon = nativeImage.createFromPath(image);
6357

6458
tray = new Tray(trayIcon);
65-
tray.setContextMenu(menu);
59+
60+
if (menuItems) {
61+
const menu = Menu.buildFromTemplate(menuItems);
62+
63+
addMenuItemClickConnector(menu.items, (id) => {
64+
electronSocket.emit('trayMenuItemClicked', id);
65+
});
66+
tray.setContextMenu(menu);
67+
}
6668
});
6769

6870
socket.on('tray-destroy', () => {

0 commit comments

Comments
 (0)