mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-17 22:26:00 +00:00
don't throw in case the tray was destroyed between calls
This commit is contained in:
@@ -5,42 +5,42 @@ let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('register-tray-click', (id) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.on('click', (event, bounds) => {
|
||||
electronSocket.emit('tray-click-event' + id, { eventArgs: event.__proto__, bounds: bounds });
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-right-click', (id) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.on('right-click', (event, bounds) => {
|
||||
electronSocket.emit('tray-right-click-event' + id, { eventArgs: event.__proto__, bounds: bounds });
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-double-click', (id) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.on('double-click', (event, bounds) => {
|
||||
electronSocket.emit('tray-double-click-event' + id, { eventArgs: event.__proto__, bounds: bounds });
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-balloon-show', (id) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.on('balloon-show', () => {
|
||||
electronSocket.emit('tray-balloon-show-event' + id);
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-balloon-click', (id) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.on('balloon-click', () => {
|
||||
electronSocket.emit('tray-balloon-click-event' + id);
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-balloon-closed', (id) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.on('balloon-closed', () => {
|
||||
electronSocket.emit('tray-balloon-closed-event' + id);
|
||||
});
|
||||
@@ -58,33 +58,33 @@ module.exports = (socket) => {
|
||||
}
|
||||
});
|
||||
socket.on('tray-destroy', () => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.destroy();
|
||||
}
|
||||
});
|
||||
socket.on('tray-setImage', (image) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.setImage(image);
|
||||
}
|
||||
});
|
||||
socket.on('tray-setPressedImage', (image) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
const img = electron_1.nativeImage.createFromPath(image);
|
||||
tray.value.setPressedImage(img);
|
||||
}
|
||||
});
|
||||
socket.on('tray-setToolTip', (toolTip) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.setToolTip(toolTip);
|
||||
}
|
||||
});
|
||||
socket.on('tray-setTitle', (title) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.setTitle(title);
|
||||
}
|
||||
});
|
||||
socket.on('tray-displayBalloon', (options) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.displayBalloon(options);
|
||||
}
|
||||
});
|
||||
@@ -95,7 +95,7 @@ module.exports = (socket) => {
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-on-event', (eventName, listenerName) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.on(eventName, (...args) => {
|
||||
if (args.length > 1) {
|
||||
electronSocket.emit(listenerName, args[1]);
|
||||
@@ -107,7 +107,7 @@ module.exports = (socket) => {
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-once-event', (eventName, listenerName) => {
|
||||
if (tray.value) {
|
||||
if (tray.value && !tray.value.isDestroyed()) {
|
||||
tray.value.once(eventName, (...args) => {
|
||||
if (args.length > 1) {
|
||||
electronSocket.emit(listenerName, args[1]);
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace ElectronNET.WebApp.Controllers
|
||||
{
|
||||
if(HybridSupport.IsElectronActive)
|
||||
{
|
||||
Electron.IpcMain.On("app-info", async (args) =>
|
||||
Electron.IpcMain.OnWithId("app-info", async (id, args) =>
|
||||
{
|
||||
string appPath = await Electron.App.GetAppPathAsync();
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace ElectronNET.WebApp.Controllers
|
||||
Electron.IpcMain.Send(mainWindow, "got-app-path", appPath);
|
||||
});
|
||||
|
||||
Electron.IpcMain.On("sys-info", async (args) =>
|
||||
Electron.IpcMain.OnWithId("sys-info", async (id, args) =>
|
||||
{
|
||||
string homePath = await Electron.App.GetPathAsync(PathName.Home);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace ElectronNET.WebApp.Controllers
|
||||
Electron.IpcMain.Send(mainWindow, "got-sys-info", homePath);
|
||||
});
|
||||
|
||||
Electron.IpcMain.On("screen-info", async (args) =>
|
||||
Electron.IpcMain.OnWithId("screen-info", async (id, args) =>
|
||||
{
|
||||
var display = await Electron.Screen.GetPrimaryDisplayAsync();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ElectronNET.WebApp
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
//Debugger.Launch();
|
||||
Debugger.Launch();
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user