Skip to content

Commit 91dd4c1

Browse files
committed
fix: unread active toggle
Signed-off-by: Adam Setch <[email protected]>
1 parent 69d80fe commit 91dd4c1

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/main/index.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ app.setAsDefaultProtocolClient(protocol);
7575
const appUpdater = new AppUpdater(mb, menuBuilder);
7676

7777
let shouldUseAlternateIdleIcon = false;
78-
let shouldUseUnreadActiveIcon = false;
78+
let shouldUseUnreadActiveIcon = true;
7979

8080
app.whenReady().then(async () => {
8181
await onFirstRunMaybe();
@@ -166,7 +166,9 @@ app.whenReady().then(async () => {
166166
(_, useUnreadActiveIcon: boolean) => {
167167
shouldUseUnreadActiveIcon = useUnreadActiveIcon;
168168

169-
if (!shouldUseUnreadActiveIcon) {
169+
if (shouldUseUnreadActiveIcon) {
170+
setActiveIcon();
171+
} else {
170172
setIdleIcon();
171173
}
172174
},
@@ -180,11 +182,6 @@ app.whenReady().then(async () => {
180182

181183
onMainEvent(EVENTS.ICON_ACTIVE, () => {
182184
if (!mb.tray.isDestroyed() && shouldUseUnreadActiveIcon) {
183-
mb.tray.setImage(
184-
menuBuilder.isUpdateAvailable()
185-
? TrayIcons.activeWithUpdate
186-
: TrayIcons.active,
187-
);
188185
}
189186
});
190187

@@ -259,6 +256,14 @@ const handleURL = (url: string) => {
259256
}
260257
};
261258

259+
function setActiveIcon() {
260+
mb.tray.setImage(
261+
menuBuilder.isUpdateAvailable()
262+
? TrayIcons.activeWithUpdate
263+
: TrayIcons.active,
264+
);
265+
}
266+
262267
function setIdleIcon() {
263268
if (shouldUseAlternateIdleIcon) {
264269
mb.tray.setImage(

src/renderer/context/App.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import {
4545
setKeyboardShortcut,
4646
setUseAlternateIdleIcon,
4747
setUseUnreadActiveIcon,
48-
updateTrayIcon,
4948
updateTrayTitle,
5049
} from '../utils/comms';
5150
import { getNotificationCount } from '../utils/notifications/notifications';
@@ -69,11 +68,13 @@ interface AppContextState {
6968
) => Promise<void>;
7069
logoutFromAccount: (account: Account) => Promise<void>;
7170

72-
notifications: AccountNotifications[];
7371
status: Status;
7472
globalError: GitifyError;
75-
removeAccountNotifications: (account: Account) => Promise<void>;
73+
74+
notifications: AccountNotifications[];
7675
fetchNotifications: () => Promise<void>;
76+
removeAccountNotifications: (account: Account) => Promise<void>;
77+
7778
markNotificationsAsRead: (notifications: Notification[]) => Promise<void>;
7879
markNotificationsAsDone: (notifications: Notification[]) => Promise<void>;
7980
unsubscribeNotification: (notification: Notification) => Promise<void>;
@@ -106,6 +107,7 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
106107
unsubscribeNotification,
107108
} = useNotifications();
108109

110+
// biome-ignore lint/correctness/useExhaustiveDependencies: restoreSettings is stable and should run only once
109111
useEffect(() => {
110112
restoreSettings();
111113
}, []);
@@ -164,13 +166,9 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
164166

165167
setUseUnreadActiveIcon(settings.useUnreadActiveIcon);
166168

167-
updateTrayIcon(count);
169+
updateTrayTitle(count.toString());
168170
}, [settings.useUnreadActiveIcon, notifications]);
169171

170-
useEffect(() => {
171-
setAutoLaunch(settings.openAtStartup);
172-
}, [settings.openAtStartup]);
173-
174172
useEffect(() => {
175173
setUseAlternateIdleIcon(settings.useAlternateIdleIcon);
176174
}, [settings.useAlternateIdleIcon]);
@@ -179,6 +177,10 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
179177
setKeyboardShortcut(settings.keyboardShortcut);
180178
}, [settings.keyboardShortcut]);
181179

180+
useEffect(() => {
181+
setAutoLaunch(settings.openAtStartup);
182+
}, [settings.openAtStartup]);
183+
182184
useEffect(() => {
183185
window.gitify.onResetApp(() => {
184186
clearState();
@@ -277,9 +279,9 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
277279

278280
// Restore settings before accounts to ensure filters are available before fetching notifications
279281
if (existing.settings) {
280-
setKeyboardShortcut(existing.settings.keyboardShortcut);
281282
setUseUnreadActiveIcon(existing.settings.useUnreadActiveIcon);
282283
setUseAlternateIdleIcon(existing.settings.useAlternateIdleIcon);
284+
setKeyboardShortcut(existing.settings.keyboardShortcut);
283285
setSettings({ ...defaultSettings, ...existing.settings });
284286
window.gitify.zoom.setLevel(
285287
zoomPercentageToLevel(existing.settings.zoomPercentage),

0 commit comments

Comments
 (0)