Skip to content

Commit 52963ff

Browse files
committed
refactor simplify
Signed-off-by: Adam Setch <[email protected]>
1 parent 26b277c commit 52963ff

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/renderer/hooks/useNotifications.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const useNotifications = (): NotificationsState => {
7474

7575
const previousNotifications = notifications;
7676
const fetchedNotifications = await getAllNotifications(state);
77+
setNotifications(fetchedNotifications);
7778

7879
// Set Global Error if all accounts have the same error
7980
const allAccountsHaveErrors =
@@ -104,21 +105,16 @@ export const useNotifications = (): NotificationsState => {
104105
fetchedNotifications,
105106
);
106107

107-
// If there are no new notifications just stop there
108-
if (!diffNotifications.length) {
109-
return;
110-
}
111-
112-
if (state.settings.playSound) {
113-
raiseSoundNotification(state.settings.notificationVolume / 100);
114-
}
108+
if (diffNotifications.length > 0) {
109+
if (state.settings.playSound) {
110+
raiseSoundNotification(state.settings.notificationVolume / 100);
111+
}
115112

116-
if (state.settings.showNotifications) {
117-
raiseNativeNotification(diffNotifications);
113+
if (state.settings.showNotifications) {
114+
raiseNativeNotification(diffNotifications);
115+
}
118116
}
119117

120-
setNotifications(fetchedNotifications);
121-
122118
setStatus('success');
123119
},
124120
[notifications],

0 commit comments

Comments
 (0)