From 23006d7309172d25da94216fe108c2d4b21a5087 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 29 Oct 2024 13:50:40 -0400 Subject: [PATCH] fix: mark as done enterprise server. additional guards Signed-off-by: Adam Setch --- src/renderer/components/NotificationRow.tsx | 5 +++- src/renderer/hooks/useNotifications.ts | 30 +++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/renderer/components/NotificationRow.tsx b/src/renderer/components/NotificationRow.tsx index 3bd305433..7992630e1 100644 --- a/src/renderer/components/NotificationRow.tsx +++ b/src/renderer/components/NotificationRow.tsx @@ -50,7 +50,10 @@ export const NotificationRow: FC = ({ openNotification(notification); - if (settings.markAsDoneOnOpen) { + if ( + isMarkAsDoneFeatureSupported(notification.account) && + settings.markAsDoneOnOpen + ) { markNotificationsAsDone([notification]); } else { markNotificationsAsRead([notification]); diff --git a/src/renderer/hooks/useNotifications.ts b/src/renderer/hooks/useNotifications.ts index 5b377f311..08911ce98 100644 --- a/src/renderer/hooks/useNotifications.ts +++ b/src/renderer/hooks/useNotifications.ts @@ -103,13 +103,24 @@ export const useNotifications = (): NotificationsState => { try { await Promise.all( - readNotifications.map((notification) => - markNotificationThreadAsRead( - notification.id, - notification.account.hostname, - notification.account.token, - ), - ), + readNotifications.map((notification) => { + if ( + isMarkAsDoneFeatureSupported(readNotifications[0].account) && + state.settings.markAsDoneOnOpen + ) { + markNotificationThreadAsDone( + notification.id, + notification.account.hostname, + notification.account.token, + ); + } else { + markNotificationThreadAsRead( + notification.id, + notification.account.hostname, + notification.account.token, + ); + } + }), ); const updatedNotifications = removeNotifications( @@ -174,7 +185,10 @@ export const useNotifications = (): NotificationsState => { notification.account.token, ); - if (state.settings.markAsDoneOnUnsubscribe) { + if ( + isMarkAsDoneFeatureSupported(notification.account) && + state.settings.markAsDoneOnUnsubscribe + ) { await markNotificationsAsDone(state, [notification]); } else { await markNotificationsAsRead(state, [notification]);