Skip to content

refactor: platform shared util #1736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/first-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'node:path';
import { app, dialog } from 'electron';

import { logError } from '../shared/logger';
import { isMacOS } from '../shared/platform';

export async function onFirstRunMaybe() {
if (isFirstRun()) {
Expand All @@ -12,7 +13,7 @@ export async function onFirstRunMaybe() {

// Ask user if the app should be moved to the applications folder.
async function promptMoveToApplicationsFolder() {
if (process.platform !== 'darwin') return;
if (!isMacOS()) return;

const isDevMode = !!process.defaultApp;
if (isDevMode || app.isInApplicationsFolder()) return;
Expand Down
3 changes: 2 additions & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import log from 'electron-log';
import { menubar } from 'menubar';

import { APPLICATION } from '../shared/constants';
import { isMacOS, isWindows } from '../shared/platform';
import { onFirstRunMaybe } from './first-run';
import { TrayIcons } from './icons';
import MenuBuilder from './menu';
Expand Down Expand Up @@ -39,7 +40,7 @@ const contextMenu = menuBuilder.buildMenu();
* Electron Auto Updater only supports macOS and Windows
* https://github.com/electron/update-electron-app
*/
if (process.platform === 'darwin' || process.platform === 'win32') {
if (isMacOS() || isWindows()) {
const updater = new Updater(mb, menuBuilder);
updater.initialize();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Menu, MenuItem } from 'electron';
import { autoUpdater } from 'electron-updater';
import type { Menubar } from 'menubar';
import { isMacOS } from '../shared/platform';
import { openLogsDirectory, resetApp, takeScreenshot } from './utils';

export default class MenuBuilder {
Expand Down Expand Up @@ -60,8 +61,7 @@ export default class MenuBuilder {
},
{
role: 'toggleDevTools',
accelerator:
process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Ctrl+Shift+I',
accelerator: isMacOS() ? 'Alt+Cmd+I' : 'Ctrl+Shift+I',
},
{
label: 'Take Screenshot',
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/settings/SystemSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DeviceDesktopIcon } from '@primer/octicons-react';
import { type FC, useContext } from 'react';
import { isLinux, isMacOS } from '../../../shared/platform';
import { AppContext } from '../../context/App';
import { OpenPreference } from '../../types';
import { Constants } from '../../utils/constants';
import { isLinux, isMacOS } from '../../utils/platform';
import { Checkbox } from '../fields/Checkbox';
import { RadioGroup } from '../fields/RadioGroup';
import { Legend } from './Legend';
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/notifications.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'node:path';

import { logError, logWarn } from '../../shared/logger';
import { isWindows } from '../../shared/platform';
import type {
AccountNotifications,
GitifyState,
Expand All @@ -13,7 +14,6 @@ import { getAccountUUID } from './auth/utils';
import { hideWindow, showWindow, updateTrayIcon } from './comms';
import { Constants } from './constants';
import { openNotification } from './links';
import { isWindows } from './platform';
import { getGitifySubjectDetails } from './subject';

export function setTrayIconColor(notifications: AccountNotifications[]) {
Expand Down
File renamed without changes.
Loading