refactor(server/utils): isMac/isWin - replace fn with boolean

those values cannot change during runtime,
=> there is no need to have these checks
as dynamic function, instead just
export the boolean value directly
This commit is contained in:
Panagiotis Papadopoulos 2025-01-22 18:42:42 +01:00
parent 7c28b93477
commit 94411cf418
5 changed files with 8 additions and 11 deletions

View File

@ -2,11 +2,10 @@
import optionService from "./options.js"; import optionService from "./options.js";
import log from "./log.js"; import log from "./log.js";
import { isElectron as getIsElectron, isMac as getIsMac } from "./utils.js"; import { isElectron as getIsElectron, isMac } from "./utils.js";
import type { KeyboardShortcut } from "./keyboard_actions_interface.js"; import type { KeyboardShortcut } from "./keyboard_actions_interface.js";
import { t } from "i18next"; import { t } from "i18next";
const isMac = getIsMac();
const isElectron = getIsElectron(); const isElectron = getIsElectron();
function getDefaultKeyboardActions() { function getDefaultKeyboardActions() {

View File

@ -17,7 +17,7 @@ const MINUTE = 60 * SECOND;
const HOUR = 60 * MINUTE; const HOUR = 60 * MINUTE;
const DAY = 24 * HOUR; const DAY = 24 * HOUR;
const NEW_LINE = isWindows() ? "\r\n" : "\n"; const NEW_LINE = isWindows ? "\r\n" : "\n";
let todaysMidnight!: Date; let todaysMidnight!: Date;

View File

@ -77,7 +77,7 @@ const defaultOptions: DefaultOption[] = [
{ name: "revisionSnapshotTimeInterval", value: "600", isSynced: true }, { name: "revisionSnapshotTimeInterval", value: "600", isSynced: true },
{ name: "revisionSnapshotNumberLimit", value: "-1", isSynced: true }, { name: "revisionSnapshotNumberLimit", value: "-1", isSynced: true },
{ name: "protectedSessionTimeout", value: "600", isSynced: true }, { name: "protectedSessionTimeout", value: "600", isSynced: true },
{ name: "zoomFactor", value: isWindows() ? "0.9" : "1.0", isSynced: false }, { name: "zoomFactor", value: isWindows ? "0.9" : "1.0", isSynced: false },
{ name: "overrideThemeFonts", value: "false", isSynced: false }, { name: "overrideThemeFonts", value: "false", isSynced: false },
{ name: "mainFontFamily", value: "theme", isSynced: false }, { name: "mainFontFamily", value: "theme", isSynced: false },
{ name: "mainFontSize", value: "100", isSynced: false }, { name: "mainFontSize", value: "100", isSynced: false },

View File

@ -321,11 +321,9 @@ export function getResourceDir() {
} }
} }
export function isMac() { export const isMac = process.platform === "darwin";
return process.platform === "darwin";
}
export function isWindows() { export const isWindows = process.platform === "win32";
return process.platform === "win32"; return process.platform === "win32";
} }

View File

@ -116,10 +116,10 @@ function getWindowExtraOpts() {
const extraOpts: Partial<BrowserWindowConstructorOptions> = {}; const extraOpts: Partial<BrowserWindowConstructorOptions> = {};
if (!optionService.getOptionBool("nativeTitleBarVisible")) { if (!optionService.getOptionBool("nativeTitleBarVisible")) {
if (isMac()) { if (isMac) {
extraOpts.titleBarStyle = "hiddenInset"; extraOpts.titleBarStyle = "hiddenInset";
extraOpts.titleBarOverlay = true; extraOpts.titleBarOverlay = true;
} else if (isWindows()) { } else if (isWindows) {
extraOpts.titleBarStyle = "hidden"; extraOpts.titleBarStyle = "hidden";
extraOpts.titleBarOverlay = true; extraOpts.titleBarOverlay = true;
} else { } else {
@ -129,7 +129,7 @@ function getWindowExtraOpts() {
} }
// Window effects (Mica) // Window effects (Mica)
if (optionService.getOptionBool("backgroundEffects") && isWindows()) { if (optionService.getOptionBool("backgroundEffects") && isWindows) {
extraOpts.backgroundMaterial = "auto"; extraOpts.backgroundMaterial = "auto";
} }