FIX application hangs after socket reconnect

Tray, Globalshortcut and other stop sending events with socket.emit after socket reconnect
This commit is contained in:
GLINTT\ppinto
2019-04-18 18:03:17 +01:00
parent 597df77508
commit 4db0ac0ebb
39 changed files with 376 additions and 333 deletions

View File

@@ -1,19 +1,21 @@
"use strict";
const electron_1 = require("electron");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('shell-showItemInFolder', (fullPath) => {
const success = electron_1.shell.showItemInFolder(fullPath);
socket.emit('shell-showItemInFolderCompleted', success);
electronSocket.emit('shell-showItemInFolderCompleted', success);
});
socket.on('shell-openItem', (fullPath) => {
const success = electron_1.shell.openItem(fullPath);
socket.emit('shell-openItemCompleted', success);
electronSocket.emit('shell-openItemCompleted', success);
});
socket.on('shell-openExternal', (url, options, callback) => {
let success = false;
if (options && callback) {
success = electron_1.shell.openExternal(url, options, (error) => {
socket.emit('shell-openExternalCallback', [url, error]);
electronSocket.emit('shell-openExternalCallback', [url, error]);
});
}
else if (options) {
@@ -22,22 +24,22 @@ module.exports = (socket) => {
else {
success = electron_1.shell.openExternal(url);
}
socket.emit('shell-openExternalCompleted', success);
electronSocket.emit('shell-openExternalCompleted', success);
});
socket.on('shell-moveItemToTrash', (fullPath) => {
const success = electron_1.shell.moveItemToTrash(fullPath);
socket.emit('shell-moveItemToTrashCompleted', success);
electronSocket.emit('shell-moveItemToTrashCompleted', success);
});
socket.on('shell-beep', () => {
electron_1.shell.beep();
});
socket.on('shell-writeShortcutLink', (shortcutPath, operation, options) => {
const success = electron_1.shell.writeShortcutLink(shortcutPath, operation, options);
socket.emit('shell-writeShortcutLinkCompleted', success);
electronSocket.emit('shell-writeShortcutLinkCompleted', success);
});
socket.on('shell-readShortcutLink', (shortcutPath) => {
const shortcutDetails = electron_1.shell.readShortcutLink(shortcutPath);
socket.emit('shell-readShortcutLinkCompleted', shortcutDetails);
electronSocket.emit('shell-readShortcutLinkCompleted', shortcutDetails);
});
};
//# sourceMappingURL=shell.js.map