Skip to content

Commit

Permalink
fix workers
Browse files Browse the repository at this point in the history
  • Loading branch information
amitojsingh366 committed Apr 4, 2021
1 parent 3722558 commit 7ed884a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion baklava/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"electron-log": "^4.3.2",
"electron-overlay-window": "^1.0.4",
"electron-updater": "^4.3.8",
"globkey": "^1.0.18",
"globkey": "^1.0.19",
"i18next": "^20.0.0",
"i18next-node-fs-backend": "^2.1.3"
},
Expand Down
11 changes: 3 additions & 8 deletions baklava/src/utils/keybinds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,7 @@ export function RegisterKeybinds(bWindows: bWindowsType) {

}
export async function exitApp() {
worker.on('message', async (msg) => {
if (msg.type === 'exit') {
await worker.terminate();
globkey.unload();
app.quit();
}
});
worker.postMessage({ type: 'exit' });
worker.removeAllListeners();
await worker.terminate();
app.quit();
}
8 changes: 1 addition & 7 deletions baklava/src/utils/keybinds/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ import globkey from 'globkey';
if (!isMainThread) {
let prev_keys = ['', '']
let shouldBreak = false;
parentPort?.on('message', (msg) => {
if (msg.type === 'exit') {
shouldBreak = true;
parentPort?.postMessage({ type: 'exit' });
}
})
while (true) {
if (shouldBreak) break;
let keys = globkey.get_keys();
let keys = globkey.getKeys();
if (keys != prev_keys) {
if (parentPort) parentPort.postMessage({ type: 'keys', keys: keys });
}
Expand Down
10 changes: 5 additions & 5 deletions baklava/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ __metadata:
electron-log: ^4.3.2
electron-overlay-window: ^1.0.4
electron-updater: ^4.3.8
globkey: ^1.0.18
globkey: ^1.0.19
i18next: ^20.0.0
i18next-node-fs-backend: ^2.1.3
lodash: ^4.17.21
Expand Down Expand Up @@ -1826,10 +1826,10 @@ __metadata:
languageName: node
linkType: hard

"globkey@npm:^1.0.18":
version: 1.0.18
resolution: "globkey@npm:1.0.18"
checksum: bb557bfa8dc33c2134ab6e59cbadec56ea9b89aa0909b16740880f74414001c93cbd935f1bb379ad15c22379618412af5970247b28ea9411057049f5f1eea4c9
"globkey@npm:^1.0.19":
version: 1.0.19
resolution: "globkey@npm:1.0.19"
checksum: 610fd1b833992545a112057e019ed48e7107bc114c17c89be941a50b2a84426ada0b5e725d96372ff7aada8fb52c2aa867f759bb660f4be2eccd77b2d06f9a8c
languageName: node
linkType: hard

Expand Down

1 comment on commit 7ed884a

@vercel
Copy link

@vercel vercel bot commented on 7ed884a Apr 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.