This commit is contained in:
Manav Rathi
2025-02-07 13:59:45 +05:30
parent 3936954ee2
commit d595a2ec15
3 changed files with 40 additions and 29 deletions

View File

@@ -24,6 +24,7 @@ import {
updateAndRestart,
updateOnNextRestart,
} from "./services/app-update";
import autoLauncher from "./services/auto-launcher";
import {
openDirectory,
openLogDirectory,
@@ -117,6 +118,10 @@ export const attachIPCHandlers = () => {
setLastShownChangelogVersion(version),
);
ipcMain.handle("isAutoLaunchEnabled", () => autoLauncher.isEnabled());
ipcMain.handle("toggleAutoLaunch", () => autoLauncher.toggleAutoLaunch());
// - App update
ipcMain.on("updateAndRestart", () => updateAndRestart());

View File

@@ -122,6 +122,10 @@ const lastShownChangelogVersion = () =>
const setLastShownChangelogVersion = (version: number) =>
ipcRenderer.invoke("setLastShownChangelogVersion", version);
const isAutoLaunchEnabled = () => ipcRenderer.invoke("isAutoLaunchEnabled");
const toggleAutoLaunch = () => ipcRenderer.invoke("toggleAutoLaunch");
const onMainWindowFocus = (cb: (() => void) | undefined) => {
ipcRenderer.removeAllListeners("mainWindowFocus");
if (cb) ipcRenderer.on("mainWindowFocus", cb);
@@ -347,6 +351,8 @@ contextBridge.exposeInMainWorld("electron", {
saveMasterKeyB64,
lastShownChangelogVersion,
setLastShownChangelogVersion,
isAutoLaunchEnabled,
toggleAutoLaunch,
onMainWindowFocus,
onOpenEnteURL,

View File

@@ -129,6 +129,35 @@ export interface Electron {
*/
onOpenEnteURL: (cb: ((url: string) => void) | undefined) => void;
/**
* Get the persisted version for the last shown changelog.
*
* See: [Note: Conditions for showing "What's new"]
*/
lastShownChangelogVersion: () => Promise<number | undefined>;
/**
* Save the given {@link version} to disk as the version of the last shown
* changelog.
*
* The value is saved to a store which is not cleared during logout.
*
* @see {@link lastShownChangelogVersion}
*/
setLastShownChangelogVersion: (version: number) => Promise<void>;
/**
* Return true if the auto launch on system startup is enabled.
*/
isAutoLaunchEnabled: () => Promise<boolean>;
/**
* Toggle the auto launch on system startup behaviour.
*
* @see {@link isAutoLaunchEnabled}
*/
toggleAutoLaunch: () => Promise<void>;
// - App update
/**
@@ -166,35 +195,6 @@ export interface Electron {
*/
skipAppUpdate: (version: string) => void;
/**
* Get the persisted version for the last shown changelog.
*
* See: [Note: Conditions for showing "What's new"]
*/
lastShownChangelogVersion: () => Promise<number | undefined>;
/**
* Save the given {@link version} to disk as the version of the last shown
* changelog.
*
* The value is saved to a store which is not cleared during logout.
*
* @see {@link lastShownChangelogVersion}
*/
setLastShownChangelogVersion: (version: number) => Promise<void>;
/**
* Return true if the auto launch on system startup is enabled.
*/
isAutoLaunchEnabled: () => Promise<boolean>;
/**
* Toggle the auto launch on system startup behaviour.
*
* @see {@link isAutoLaunchEnabled}
*/
toggleAutoLaunch: () => Promise<void>;
// - FS
/**