feat: implement progressBarMode none for electron

This commit is contained in:
theUGG0 2025-08-15 00:54:15 +03:00
parent 536a218650
commit 0a64079de7
2 changed files with 21 additions and 4 deletions

View file

@ -104,7 +104,10 @@ export interface ElectronAPI {
setDoneRegisterBeforeClose(id: string): void;
setProgressBar(args: { progress: number; progressBarMode: 'normal' | 'pause' }): void;
setProgressBar(args: {
progress: number;
progressBarMode: 'normal' | 'pause' | 'none';
}): void;
sendAppSettingsToElectron(globalCfg: GlobalConfigState): void;

View file

@ -1,6 +1,14 @@
// FRONTEND EVENTS
// ---------------
import { app, dialog, globalShortcut, ipcMain, IpcMainEvent, shell } from 'electron';
import {
app,
dialog,
globalShortcut,
ipcMain,
IpcMainEvent,
ProgressBarOptions,
shell,
} from 'electron';
import { IPC } from './shared-with-frontend/ipc-events.const';
import { lockscreen } from './lockscreen';
import { errorHandlerWithFrontendInform } from './error-handler-with-frontend-inform';
@ -83,10 +91,16 @@ export const initIpcInterfaces = (): void => {
}
});
ipcMain.on(IPC.SET_PROGRESS_BAR, (ev, { progress, mode }) => {
ipcMain.on(IPC.SET_PROGRESS_BAR, (ev, { progress, progressBarMode }) => {
const mainWin = getWin();
if (mainWin) {
mainWin.setProgressBar(Math.min(Math.max(progress, 0), 1), { mode });
if (progressBarMode === 'none') {
mainWin.setProgressBar(-1);
} else {
mainWin.setProgressBar(Math.min(Math.max(progress, 0), 1), {
mode: progressBarMode as ProgressBarOptions['mode'],
});
}
}
});