From d323a3ad2909d026982af41bf83c9ba610d3acda Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 3 Oct 2026 12:06:40 -0400 Subject: [PATCH 1/3] refactor(sonar): resolve S3358 nested ternary operators --- src/main/handlers/tray.ts | 15 +++++++------ .../components/settings/SystemSettings.tsx | 11 +++++----- src/renderer/routes/Accounts.tsx | 22 +++++++++---------- src/renderer/stores/useAccountsStore.ts | 13 +++++------ src/renderer/stores/useSettingsStore.ts | 15 ++++++++----- src/renderer/utils/system/keyboardShortcut.ts | 5 ++++- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/main/handlers/tray.ts b/src/main/handlers/tray.ts index 67b552a1b..b3f013d91 100644 --- a/src/main/handlers/tray.ts +++ b/src/main/handlers/tray.ts @@ -21,13 +21,14 @@ export function registerTrayHandlers(mb: Menubar): void { return; } const { notificationsCount, isOnline } = status; - const icon = !isOnline - ? TrayIcons.offline - : notificationsCount < 0 - ? TrayIcons.error - : notificationsCount > 0 && highlightUnread - ? TrayIcons.active - : getIdleTrayIcon(appearance); + let icon = getIdleTrayIcon(appearance); + if (!isOnline) { + icon = TrayIcons.offline; + } else if (notificationsCount < 0) { + icon = TrayIcons.error; + } else if (notificationsCount > 0 && highlightUnread) { + icon = TrayIcons.active; + } mb.tray.setImage(icon); }; diff --git a/src/renderer/components/settings/SystemSettings.tsx b/src/renderer/components/settings/SystemSettings.tsx index 1b2c5813f..af8aaf4ad 100644 --- a/src/renderer/components/settings/SystemSettings.tsx +++ b/src/renderer/components/settings/SystemSettings.tsx @@ -121,6 +121,11 @@ export const SystemSettings: FC = () => { const hasLiveModifiers = liveModifierAccelerator.length > 0; const liveModifierDisplay = formatAcceleratorForDisplay(liveModifierAccelerator, isMac); + let shortcutButtonLabel = shortcutDisplay; + if (recordingShortcut) { + shortcutButtonLabel = hasLiveModifiers ? `${liveModifierDisplay}…` : 'Press keys…'; + } + return (
System @@ -237,11 +242,7 @@ export const SystemSettings: FC = () => { tabIndex={-1} > - {recordingShortcut - ? hasLiveModifiers - ? `${liveModifierDisplay}…` - : 'Press keys…' - : shortcutDisplay} + {shortcutButtonLabel} { const navigate = useNavigate(); @@ -232,17 +242,7 @@ export const AccountsRoute: FC = () => { ( - - )} + icon={() => } onClick={() => navigate('/account-scopes', { state: { account }, diff --git a/src/renderer/stores/useAccountsStore.ts b/src/renderer/stores/useAccountsStore.ts index 69ac7fd2f..a689d30a8 100644 --- a/src/renderer/stores/useAccountsStore.ts +++ b/src/renderer/stores/useAccountsStore.ts @@ -109,13 +109,12 @@ const useAccountsStore = create()( ); set({ - accounts: accounts.flatMap((account, index) => - replacesAccount(account) - ? index === existingAccountIndex - ? [newAccount] - : [] - : [account], - ), + accounts: accounts.flatMap((account, index) => { + if (!replacesAccount(account)) { + return [account]; + } + return index === existingAccountIndex ? [newAccount] : []; + }), }); } else { set({ accounts: [...accounts, newAccount] }); diff --git a/src/renderer/stores/useSettingsStore.ts b/src/renderer/stores/useSettingsStore.ts index 6f965758b..644aecd00 100644 --- a/src/renderer/stores/useSettingsStore.ts +++ b/src/renderer/stores/useSettingsStore.ts @@ -1,6 +1,8 @@ import { create } from 'zustand'; import { persist, subscribeWithSelector } from 'zustand/middleware'; +import type { TrayIconAppearance } from '../../shared/events'; + import { Constants } from '../constants'; import type { SettingsStore } from './types'; @@ -49,15 +51,16 @@ const useSettingsStore = create()( useAlternateIdleIcon: undefined, ...persisted, }; + let trayIconAppearance: TrayIconAppearance = 'auto'; + if (useAlternateIdleIcon === true) { + trayIconAppearance = 'light'; + } else if (useAlternateIdleIcon === false && !window.gitify.platform.isMacOS()) { + trayIconAppearance = 'dark'; + } return { ...DEFAULT_SETTINGS_STATE, ...settings, - trayIconAppearance: - useAlternateIdleIcon === true - ? 'light' - : useAlternateIdleIcon === false && !window.gitify.platform.isMacOS() - ? 'dark' - : 'auto', + trayIconAppearance, }; }, }, diff --git a/src/renderer/utils/system/keyboardShortcut.ts b/src/renderer/utils/system/keyboardShortcut.ts index f8090f79c..d479166c9 100644 --- a/src/renderer/utils/system/keyboardShortcut.ts +++ b/src/renderer/utils/system/keyboardShortcut.ts @@ -91,7 +91,10 @@ export function formatAcceleratorForDisplay(accelerator: string, isMac: boolean) .split('+') .map((segment) => { const entry = MODIFIER_SEGMENTS.find((m) => m.accelerator === segment); - return entry ? (isMac ? entry.mac : entry.other) : segment; + if (!entry) { + return segment; + } + return isMac ? entry.mac : entry.other; }) .join(isMac ? '·' : '+'); } From b71145b694fe538911ae8a7ec5043aed06dd5206 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 3 Oct 2026 17:19:56 -0400 Subject: [PATCH 2/3] refactor(sonar): use IconColor.WARNING for scope icon --- src/renderer/routes/Accounts.tsx | 2 +- src/renderer/types.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/routes/Accounts.tsx b/src/renderer/routes/Accounts.tsx index b633edea2..84c853bad 100644 --- a/src/renderer/routes/Accounts.tsx +++ b/src/renderer/routes/Accounts.tsx @@ -43,7 +43,7 @@ function getScopeIconClassName(account: Account): string { return IconColor.GREEN; } if (hasAlternateScopes(account)) { - return 'text-gitify-warning'; + return IconColor.WARNING; } return ''; } diff --git a/src/renderer/types.ts b/src/renderer/types.ts index f1da43d9d..205168a0f 100644 --- a/src/renderer/types.ts +++ b/src/renderer/types.ts @@ -265,6 +265,7 @@ export enum IconColor { PURPLE = 'text-gitify-icon-done', RED = 'text-gitify-icon-closed', YELLOW = 'text-gitify-icon-attention', + WARNING = 'text-gitify-warning', } export enum Opacity { From 8228016266c11dddae4b220e323394d3d9bfeadd Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 3 Oct 2026 17:22:39 -0400 Subject: [PATCH 3/3] Revert "refactor(sonar): use IconColor.WARNING for scope icon" This reverts commit b71145b694fe538911ae8a7ec5043aed06dd5206. --- src/renderer/routes/Accounts.tsx | 2 +- src/renderer/types.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/renderer/routes/Accounts.tsx b/src/renderer/routes/Accounts.tsx index 84c853bad..b633edea2 100644 --- a/src/renderer/routes/Accounts.tsx +++ b/src/renderer/routes/Accounts.tsx @@ -43,7 +43,7 @@ function getScopeIconClassName(account: Account): string { return IconColor.GREEN; } if (hasAlternateScopes(account)) { - return IconColor.WARNING; + return 'text-gitify-warning'; } return ''; } diff --git a/src/renderer/types.ts b/src/renderer/types.ts index 205168a0f..f1da43d9d 100644 --- a/src/renderer/types.ts +++ b/src/renderer/types.ts @@ -265,7 +265,6 @@ export enum IconColor { PURPLE = 'text-gitify-icon-done', RED = 'text-gitify-icon-closed', YELLOW = 'text-gitify-icon-attention', - WARNING = 'text-gitify-warning', } export enum Opacity {