Skip to content

Commit 0885054

Browse files
authored
refactor: generalize color setting and skip detailed subject fetching when disabled (#1005)
1 parent 3cb6a4a commit 0885054

File tree

10 files changed

+83
-91
lines changed

10 files changed

+83
-91
lines changed

src/__mocks__/mock-state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const mockSettings: SettingsState = {
1515
showNotificationsCountInTray: false,
1616
openAtStartup: false,
1717
theme: Theme.SYSTEM,
18-
colors: false,
18+
detailedNotifications: false,
1919
markAsDoneOnOpen: false,
2020
showAccountHostname: false,
2121
};

src/components/NotificationRow.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
7373
const reason = formatReason(notification.reason);
7474
const NotificationIcon = getNotificationTypeIcon(notification.subject);
7575
const iconColor = getNotificationTypeIconColor(notification.subject);
76-
const realIconColor = settings
77-
? (settings.colors && iconColor) || ''
78-
: iconColor;
7976
const updatedAt = formatDistanceToNow(parseISO(notification.updated_at), {
8077
addSuffix: true,
8178
});
@@ -91,7 +88,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
9188
return (
9289
<div className="flex space-x-3 py-2 px-3 bg-white dark:bg-gray-dark dark:text-white hover:bg-gray-100 dark:hover:bg-gray-darker border-b border-gray-100 dark:border-gray-darker group">
9390
<div
94-
className={`flex justify-center items-center w-5 ${realIconColor}`}
91+
className={`flex justify-center items-center w-5 ${iconColor}`}
9592
title={notificationTitle}
9693
>
9794
<NotificationIcon size={18} aria-label={notification.subject.type} />

src/context/App.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ describe('context/App.tsx', () => {
318318
showNotificationsCountInTray: false,
319319
openAtStartup: false,
320320
theme: 'SYSTEM',
321-
colors: null,
321+
detailedNotifications: false,
322322
markAsDoneOnOpen: false,
323323
showAccountHostname: false,
324324
},
@@ -362,7 +362,7 @@ describe('context/App.tsx', () => {
362362
showNotificationsCountInTray: false,
363363
openAtStartup: true,
364364
theme: 'SYSTEM',
365-
colors: null,
365+
detailedNotifications: false,
366366
markAsDoneOnOpen: false,
367367
showAccountHostname: false,
368368
},

src/context/App.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const defaultSettings: SettingsState = {
4141
showNotificationsCountInTray: false,
4242
openAtStartup: false,
4343
theme: Theme.SYSTEM,
44-
colors: null,
44+
detailedNotifications: false,
4545
markAsDoneOnOpen: false,
4646
showAccountHostname: false,
4747
};
@@ -90,7 +90,7 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
9090
unsubscribeNotification,
9191
markRepoNotifications,
9292
markRepoNotificationsDone,
93-
} = useNotifications(settings.colors);
93+
} = useNotifications();
9494

9595
useEffect(() => {
9696
restoreSettings();
@@ -103,7 +103,11 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
103103
// biome-ignore lint/correctness/useExhaustiveDependencies: We only want fetchNotifications to be called for a subset of settings changes.
104104
useEffect(() => {
105105
fetchNotifications(accounts, settings);
106-
}, [settings.participating, settings.showBots]);
106+
}, [
107+
settings.participating,
108+
settings.showBots,
109+
settings.detailedNotifications,
110+
]);
107111

108112
// biome-ignore lint/correctness/useExhaustiveDependencies: We only want fetchNotifications to be called for certain account changes.
109113
useEffect(() => {

0 commit comments

Comments
 (0)