fixes etc

This commit is contained in:
Vendicated
2026-04-05 04:07:23 +02:00
parent f3e01c2ba4
commit cf3667c151
12 changed files with 150 additions and 22 deletions
+2
View File
@@ -13,3 +13,5 @@ export const AppEvents = new EventEmitter<{
userAssetChanged: [UserAssetType];
setTrayVariant: ["tray" | "trayUnread"];
}>();
export const appReady = new Promise<void>(resolve => AppEvents.once("appLoaded", () => resolve()));
+1 -1
View File
@@ -167,5 +167,5 @@ app.on("second-instance", (_e, _argv, _cwd, data) => {
const { args } = data as { args: typeof CommandLine; IS_DEV: boolean };
const { "run-shortcut": shortcut } = args.values;
if (shortcut) sendRendererCommand(IpcCommands.HANDLE_KEY_BIND, shortcut);
if (shortcut) sendRendererCommand(IpcCommands.KEY_BINDS_HANDLE, shortcut);
});
+4 -1
View File
@@ -8,6 +8,7 @@ import { randomUUID } from "crypto";
import { ipcMain } from "electron";
import { IpcEvents } from "shared/IpcEvents";
import { appReady } from "./events";
import { mainWin } from "./mainWindow";
const resolvers = new Map<string, Record<"resolve" | "reject", (data: any) => void>>();
@@ -30,7 +31,9 @@ export interface IpcResponse {
*
* You must add a handler for the message in the renderer process.
*/
export function sendRendererCommand<T = any>(message: string, data?: any) {
export async function sendRendererCommand<T = any>(message: string, data?: any) {
await appReady;
if (mainWin.isDestroyed()) {
console.warn("Main window is destroyed, cannot send IPC command:", message);
return Promise.reject(new Error("Main window is destroyed"));
+7 -5
View File
@@ -12,7 +12,6 @@ import { Settings } from "./settings";
function unregisterKeyBinds() {
if (!app.isReady()) return;
globalShortcut.unregisterAll();
}
@@ -21,15 +20,18 @@ export async function registerKeyBinds() {
unregisterKeyBinds();
let success = true;
for (const { action, enabled, key } of Settings.store.keyBinds || []) {
if (!enabled || !key || action === "unassigned") continue;
console.log(
key,
"SUCCESS",
globalShortcut.register(key, () => sendRendererCommand(IpcCommands.HANDLE_KEY_BIND, action))
const registeredSuccessfully = globalShortcut.register(key, () =>
sendRendererCommand(IpcCommands.KEY_BINDS_HANDLE, action)
);
success &&= registeredSuccessfully;
}
sendRendererCommand(IpcCommands.KEY_BINDS_SET_STATUS, success);
}
Settings.addChangeListener("keyBinds", registerKeyBinds);