Handle
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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,
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user