442: maintain references between socket.io connection events

https://github.com/ElectronNET/Electron.NET/issues/442

remove deletes of modules during disconnect
add delete of hostHook during disconnect
check if modules exist before importing them curring connect
move local caches of modules into global scope.
This commit is contained in:
Dan Gidman
2020-10-06 11:29:53 -05:00
parent b525bf1a9a
commit e73655bd68
11 changed files with 429 additions and 412 deletions

View File

@@ -1,39 +1,39 @@
"use strict";
const electron_1 = require("electron");
const notifications = [];
let electronSocket;
module.exports = (socket) => {
var electron_1 = require("electron");
var notifications = (global['notifications'] = global['notifications'] || []);
var electronSocket;
module.exports = function (socket) {
electronSocket = socket;
socket.on('createNotification', (options) => {
const notification = new electron_1.Notification(options);
let haveEvent = false;
socket.on('createNotification', function (options) {
var notification = new electron_1.Notification(options);
var haveEvent = false;
if (options.showID) {
haveEvent = true;
notification.on('show', () => {
notification.on('show', function () {
electronSocket.emit('NotificationEventShow', options.showID);
});
}
if (options.clickID) {
haveEvent = true;
notification.on('click', () => {
notification.on('click', function () {
electronSocket.emit('NotificationEventClick', options.clickID);
});
}
if (options.closeID) {
haveEvent = true;
notification.on('close', () => {
notification.on('close', function () {
electronSocket.emit('NotificationEventClose', options.closeID);
});
}
if (options.replyID) {
haveEvent = true;
notification.on('reply', (event, value) => {
notification.on('reply', function (event, value) {
electronSocket.emit('NotificationEventReply', [options.replyID, value]);
});
}
if (options.actionID) {
haveEvent = true;
notification.on('action', (event, value) => {
notification.on('action', function (event, value) {
electronSocket.emit('NotificationEventAction', [options.actionID, value]);
});
}
@@ -42,9 +42,8 @@ module.exports = (socket) => {
}
notification.show();
});
socket.on('notificationIsSupported', () => {
const isSupported = electron_1.Notification.isSupported;
socket.on('notificationIsSupported', function () {
var isSupported = electron_1.Notification.isSupported;
electronSocket.emit('notificationIsSupportedComplete', isSupported);
});
};
//# sourceMappingURL=notification.js.map