Skip to content

Commit 9d1614a

Browse files
authored
fix: inconsistent notification state (#1037)
1 parent 8ce79fe commit 9d1614a

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/components/NotificationRow.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,19 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
3636
markNotificationRead,
3737
markNotificationDone,
3838
unsubscribeNotification,
39+
notifications,
3940
} = useContext(AppContext);
4041

41-
const pressTitle = useCallback(() => {
42-
openBrowser();
42+
const openNotification = useCallback(() => {
43+
openInBrowser(notification, accounts);
4344

4445
if (settings.markAsDoneOnOpen) {
4546
markNotificationDone(notification.id, hostname);
4647
} else {
4748
// no need to mark as read, github does it by default when opening it
4849
removeNotificationFromState(notification.id, hostname);
4950
}
50-
}, [settings]);
51-
52-
const openBrowser = useCallback(
53-
() => openInBrowser(notification, accounts),
54-
[notification],
55-
);
51+
}, [notifications, notification, accounts, settings]); // notifications required here to prevent weird state issues
5652

5753
const unsubscribe = (event: MouseEvent<HTMLElement>) => {
5854
// Don't trigger onClick of parent element.
@@ -96,8 +92,8 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
9692

9793
<div
9894
className="flex-1 overflow-hidden"
99-
onClick={() => pressTitle()}
100-
onKeyDown={() => pressTitle()}
95+
onClick={() => openNotification()}
96+
onKeyDown={() => openNotification()}
10197
>
10298
<div
10399
className="mb-1 text-sm whitespace-nowrap overflow-ellipsis overflow-hidden cursor-pointer"

0 commit comments

Comments
 (0)