Skip to content

Commit

Permalink
refactor: use isMac and isWindows util funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
pano9000 committed Jan 2, 2025
1 parent 13235a2 commit ac77d20
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/services/keyboard_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import optionService from "./options.js";
import log from "./log.js";
import { isElectron as getIsElectron } from "./utils.js";
import { isElectron as getIsElectron, isMac as getIsMac } from "./utils.js";
import { KeyboardShortcut } from './keyboard_actions_interface.js';
import { t } from "i18next";

const isMac = process.platform === "darwin";
const isMac = getIsMac();
const isElectron = getIsElectron();

function getDefaultKeyboardActions() {
Expand Down
3 changes: 2 additions & 1 deletion src/services/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Request, Response } from "express";
import fs from "fs";
import dataDir from "./data_dir.js";
import cls from "./cls.js";
import { isWindows } from "./utils.js";

if (!fs.existsSync(dataDir.LOG_DIR)) {
fs.mkdirSync(dataDir.LOG_DIR, 0o700);
Expand All @@ -16,7 +17,7 @@ const MINUTE = 60 * SECOND;
const HOUR = 60 * MINUTE;
const DAY = 24 * HOUR;

const NEW_LINE = process.platform === "win32" ? '\r\n' : '\n';
const NEW_LINE = isWindows() ? '\r\n' : '\n';

let todaysMidnight!: Date;

Expand Down
4 changes: 2 additions & 2 deletions src/services/options_init.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import optionService from "./options.js";
import type { OptionMap } from "./options.js";
import appInfo from "./app_info.js";
import { randomSecureToken } from "./utils.js";
import { randomSecureToken, isWindows } from "./utils.js";
import log from "./log.js";
import dateUtils from "./date_utils.js";
import keyboardActions from "./keyboard_actions.js";
Expand Down Expand Up @@ -72,7 +72,7 @@ const defaultOptions: DefaultOption[] = [
{ name: 'revisionSnapshotTimeInterval', value: '600', isSynced: true },
{ name: 'revisionSnapshotNumberLimit', value: '-1', isSynced: true },
{ name: 'protectedSessionTimeout', value: '600', isSynced: true },
{ name: 'zoomFactor', value: process.platform === "win32" ? '0.9' : '1.0', isSynced: false },
{ name: 'zoomFactor', value: isWindows() ? '0.9' : '1.0', isSynced: false },
{ name: 'overrideThemeFonts', value: 'false', isSynced: false },
{ name: 'mainFontFamily', value: 'theme', isSynced: false },
{ name: 'mainFontSize', value: '100', isSynced: false },
Expand Down
10 changes: 4 additions & 6 deletions src/services/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import cls from "./cls.js";
import keyboardActionsService from "./keyboard_actions.js";
import remoteMain from "@electron/remote/main/index.js";
import { App, BrowserWindow, BrowserWindowConstructorOptions, WebContents, ipcMain } from 'electron';
import { isMac, isWindows } from "./utils.js";

import { fileURLToPath } from "url";
import { dirname } from "path";
Expand Down Expand Up @@ -115,14 +116,11 @@ async function createMainWindow(app: App) {
function getWindowExtraOpts() {
const extraOpts: Partial<BrowserWindowConstructorOptions> = {};

const isMac = (process.platform === "darwin");
const isWindows = (process.platform === "win32");

if (!optionService.getOptionBool('nativeTitleBarVisible')) {
if (isMac) {
if (isMac()) {
extraOpts.titleBarStyle = "hiddenInset";
extraOpts.titleBarOverlay = true;
} else if (isWindows) {
} else if (isWindows()) {
extraOpts.titleBarStyle = "hidden";
extraOpts.titleBarOverlay = true;
} else {
Expand All @@ -132,7 +130,7 @@ function getWindowExtraOpts() {
}

// Window effects (Mica)
if (optionService.getOptionBool('backgroundEffects') && isWindows) {
if (optionService.getOptionBool('backgroundEffects') && isWindows()) {
extraOpts.backgroundMaterial = "auto";
}

Expand Down

0 comments on commit ac77d20

Please sign in to comment.