Skip to content

refactor: generalize color setting and skip detailed subject fetching when disabled #1005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2024
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
2 changes: 1 addition & 1 deletion src/__mocks__/mock-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const mockSettings: SettingsState = {
showNotificationsCountInTray: false,
openAtStartup: false,
theme: Theme.SYSTEM,
colors: false,
detailedNotifications: false,
markAsDoneOnOpen: false,
showAccountHostname: false,
};
5 changes: 1 addition & 4 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
const reason = formatReason(notification.reason);
const NotificationIcon = getNotificationTypeIcon(notification.subject);
const iconColor = getNotificationTypeIconColor(notification.subject);
const realIconColor = settings
? (settings.colors && iconColor) || ''
: iconColor;
const updatedAt = formatDistanceToNow(parseISO(notification.updated_at), {
addSuffix: true,
});
Expand All @@ -91,7 +88,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
return (
<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">
<div
className={`flex justify-center items-center w-5 ${realIconColor}`}
className={`flex justify-center items-center w-5 ${iconColor}`}
title={notificationTitle}
>
<NotificationIcon size={18} aria-label={notification.subject.type} />
Expand Down
4 changes: 2 additions & 2 deletions src/context/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('context/App.tsx', () => {
showNotificationsCountInTray: false,
openAtStartup: false,
theme: 'SYSTEM',
colors: null,
detailedNotifications: false,
markAsDoneOnOpen: false,
showAccountHostname: false,
},
Expand Down Expand Up @@ -362,7 +362,7 @@ describe('context/App.tsx', () => {
showNotificationsCountInTray: false,
openAtStartup: true,
theme: 'SYSTEM',
colors: null,
detailedNotifications: false,
markAsDoneOnOpen: false,
showAccountHostname: false,
},
Expand Down
10 changes: 7 additions & 3 deletions src/context/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const defaultSettings: SettingsState = {
showNotificationsCountInTray: false,
openAtStartup: false,
theme: Theme.SYSTEM,
colors: null,
detailedNotifications: false,
markAsDoneOnOpen: false,
showAccountHostname: false,
};
Expand Down Expand Up @@ -90,7 +90,7 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
unsubscribeNotification,
markRepoNotifications,
markRepoNotificationsDone,
} = useNotifications(settings.colors);
} = useNotifications();

useEffect(() => {
restoreSettings();
Expand All @@ -102,7 +102,11 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {

useEffect(() => {
fetchNotifications(accounts, settings);
}, [settings.participating, settings.showBots]);
}, [
settings.participating,
settings.showBots,
settings.detailedNotifications,
]);

useEffect(() => {
fetchNotifications(accounts, settings);
Expand Down
Loading