Compare commits

...

1 Commits

Author SHA1 Message Date
Michael Telatynski
4782e0469a Small step in tidying the IPCs
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2025-06-11 13:21:06 +01:00
3 changed files with 27 additions and 23 deletions

View File

@@ -39,20 +39,15 @@ ipcMain.on("loudNotification", function (): void {
});
let powerSaveBlockerId: number | null = null;
ipcMain.on("app_onAction", function (_ev: IpcMainEvent, payload) {
switch (payload.action) {
case "call_state": {
if (powerSaveBlockerId !== null && powerSaveBlocker.isStarted(powerSaveBlockerId)) {
if (payload.state === "ended") {
powerSaveBlocker.stop(powerSaveBlockerId);
powerSaveBlockerId = null;
}
} else {
if (powerSaveBlockerId === null && payload.state === "connected") {
powerSaveBlockerId = powerSaveBlocker.start("prevent-display-sleep");
}
}
break;
ipcMain.on("callState", function (_ev: IpcMainEvent, state) {
if (powerSaveBlockerId !== null && powerSaveBlocker.isStarted(powerSaveBlockerId)) {
if (state === "ended") {
powerSaveBlocker.stop(powerSaveBlockerId);
powerSaveBlockerId = null;
}
} else {
if (powerSaveBlockerId === null && state === "connected") {
powerSaveBlockerId = powerSaveBlocker.start("prevent-display-sleep");
}
}
});
@@ -65,15 +60,9 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) {
let ret: any;
switch (payload.name) {
case "getUpdateFeedUrl":
ret = autoUpdater.getFeedURL();
break;
case "setLanguage":
global.appLocalization.setAppLocale(args[0]);
break;
case "getAppVersion":
ret = app.getVersion();
break;
case "focusWindow":
if (global.mainWindow.isMinimized()) {
global.mainWindow.restore();
@@ -229,4 +218,8 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) {
});
});
ipcMain.handle("getCanSelfUpdate", () => !!autoUpdater.getFeedURL());
ipcMain.handle("getVersion", () => app.getVersion());
ipcMain.handle("getConfig", () => global.vectorConfig);

View File

@@ -14,7 +14,6 @@ import { ipcRenderer, contextBridge, IpcRendererEvent } from "electron";
// handing out generalised messaging access.
const CHANNELS = [
"app_onAction",
"before-quit",
"check_updates",
"install_update",
@@ -51,17 +50,21 @@ contextBridge.exposeInMainWorld("electron", {
},
async initialise(): Promise<{
version: string;
protocol: string;
sessionId: string;
config: IConfigOptions;
supportedSettings: Record<string, boolean>;
canSelfUpdate: boolean;
}> {
const [{ protocol, sessionId }, config, supportedSettings] = await Promise.all([
const [{ protocol, sessionId }, config, supportedSettings, version, canSelfUpdate] = await Promise.all([
ipcRenderer.invoke("getProtocol"),
ipcRenderer.invoke("getConfig"),
ipcRenderer.invoke("getSupportedSettings"),
ipcRenderer.invoke("getVersion"),
ipcRenderer.invoke("canSelfUpdate"),
]);
return { protocol, sessionId, config, supportedSettings };
return { protocol, sessionId, config, supportedSettings, version, canSelfUpdate };
},
async setSettingValue(settingName: string, value: any): Promise<void> {

View File

@@ -91,6 +91,14 @@ const Settings: Record<string, Setting> = {
Store.instance?.set("enableContentProtection", value);
},
},
"locale": {
async read(): Promise<any> {
return Store.instance?.get("locale");
},
async write(value: any): Promise<void> {
global.appLocalization.setAppLocale(value);
},
},
};
ipcMain.handle("getSupportedSettings", async () => {