Skip to content
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
15 changes: 8 additions & 7 deletions src/main/handlers/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
11 changes: 6 additions & 5 deletions src/renderer/components/settings/SystemSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<fieldset>
<Title icon={DeviceDesktopIcon}>System</Title>
Expand Down Expand Up @@ -237,11 +242,7 @@ export const SystemSettings: FC = () => {
tabIndex={-1}
>
<Text as="strong" className="text-gitify-caution">
{recordingShortcut
? hasLiveModifiers
? `${liveModifierDisplay}…`
: 'Press keys…'
: shortcutDisplay}
{shortcutButtonLabel}
</Text>
</Button>
<IconButton
Expand Down
22 changes: 11 additions & 11 deletions src/renderer/routes/Accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
import { openAccountProfile, openAccountSettings, openHost } from '../utils/system/links';
import { getPlatformIcon } from '../utils/ui/icons';

function getScopeIconClassName(account: Account): string {
if (hasRecommendedScopes(account)) {
return IconColor.GREEN;
}
if (hasAlternateScopes(account)) {
return 'text-gitify-warning';
}
return '';
}

export const AccountsRoute: FC = () => {
const navigate = useNavigate();

Expand Down Expand Up @@ -232,17 +242,7 @@
<IconButton
aria-label={`View scopes for ${account.user?.login}`}
data-testid="account-view-scopes"
icon={() => (
<ShieldCheckIcon
className={
hasRecommendedScopes(account)
? IconColor.GREEN
: hasAlternateScopes(account)
? 'text-gitify-warning'
: ''
}
/>
)}
icon={() => <ShieldCheckIcon className={getScopeIconClassName(account)} />}

Check warning on line 245 in src/renderer/routes/Accounts.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this component definition out of the parent component and pass data as props.

See more on https://sonarcloud.io/project/issues?id=gitify-app_gitify&issues=AaEDj931b7mETkQZhzUj&open=AaEDj931b7mETkQZhzUj&pullRequest=3360
onClick={() =>
navigate('/account-scopes', {
state: { account },
Expand Down
13 changes: 6 additions & 7 deletions src/renderer/stores/useAccountsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ const useAccountsStore = create<AccountsStore>()(
);

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] });
Expand Down
15 changes: 9 additions & 6 deletions src/renderer/stores/useSettingsStore.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -49,15 +51,16 @@ const useSettingsStore = create<SettingsStore>()(
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,
};
},
},
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/utils/system/keyboardShortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? '·' : '+');
}
Loading