Skip to content

Commit

Permalink
make globkey worker work better
Browse files Browse the repository at this point in the history
  • Loading branch information
amitojsingh366 committed Apr 5, 2021
1 parent 945d7e8 commit 9f27b1f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion baklava/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dogehouse",
"version": "1.0.36",
"version": "1.0.37",
"description": "Taking voice conversations to the moon 🚀",
"main": "./dist/electron.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions baklava/src/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import i18n from "i18next";
import Backend from "i18next-node-fs-backend";
import { autoUpdater } from "electron-updater";
import { RegisterKeybinds, exitApp } from "./utils/keybinds";
import { RegisterKeybinds, stopWorkersAndExitApp } from "./utils/keybinds";
import { HandleVoiceTray } from "./utils/tray";
import { ALLOWED_HOSTS, isLinux, isMac, MENU_TEMPLATE } from "./constants";
import path from "path";
Expand Down Expand Up @@ -191,7 +191,7 @@ if (!instanceLock) {
if (process.env.hotReload) {
app.relaunch();
}
exitApp();
stopWorkersAndExitApp();
} else {
app.on("ready", () => {
localize().then(() => {
Expand Down Expand Up @@ -246,7 +246,7 @@ autoUpdater.on('update-not-available', () => {
});

app.on("window-all-closed", async () => {
await exitApp();
await stopWorkersAndExitApp();
});
app.on("activate", () => {
if (mainWindow === null) {
Expand Down
2 changes: 1 addition & 1 deletion baklava/src/utils/keybinds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function RegisterKeybinds(bWindows: bWindowsType) {
}
});
}
export async function exitApp() {
export async function stopWorkersAndExitApp() {
worker.removeAllListeners();
await worker.terminate();
globkey.unload();
Expand Down
2 changes: 0 additions & 2 deletions baklava/src/utils/keybinds/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { isMainThread, parentPort } from 'worker_threads';
import globkey from 'globkey';

if (!isMainThread) {
let shouldBreak = false;
globkey.start();
while (true) {
if (shouldBreak) break;
let keys = globkey.getKeys();
if (parentPort) parentPort.postMessage({ type: 'keys', keys: keys });
}
Expand Down

1 comment on commit 9f27b1f

@vercel
Copy link

@vercel vercel bot commented on 9f27b1f Apr 5, 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.