Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 8b55d30

Browse files
authored
Merge pull request #4648 from withspectrum/fix-mark-single-notification-as-seen
Do not call `markSingleNotificationSeen` for all client-side notifications
2 parents 92c2939 + 694eae3 commit 8b55d30

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/views/navbar/components/notificationsTab.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,16 @@ class NotificationsTab extends React.Component<Props, State> {
236236
const newNotifications =
237237
notifications &&
238238
notifications.map(n => Object.assign({}, n, { isSeen: true }));
239-
this.processAndMarkSeenNotifications(newNotifications);
239+
this.processAndMarkSeenNotifications(newNotifications, false);
240240
// otherwise
241241
return markAllNotificationsSeen().catch(err => {
242242
console.error(err);
243243
// Undo the optimistic update from above
244-
this.processAndMarkSeenNotifications(oldNotifications);
244+
this.processAndMarkSeenNotifications(oldNotifications, false);
245245
});
246246
};
247247

248-
processAndMarkSeenNotifications = stateNotifications => {
248+
processAndMarkSeenNotifications = (stateNotifications, sync = true) => {
249249
const {
250250
data: { notifications },
251251
location,
@@ -321,12 +321,14 @@ class NotificationsTab extends React.Component<Props, State> {
321321
});
322322

323323
// and then mark it as seen on the server
324-
client.mutate({
325-
mutation: markSingleNotificationSeenMutation,
326-
variables: {
327-
id: n.id,
328-
},
329-
});
324+
if (sync) {
325+
client.mutate({
326+
mutation: markSingleNotificationSeenMutation,
327+
variables: {
328+
id: n.id,
329+
},
330+
});
331+
}
330332

331333
return newNotification;
332334
} else {

0 commit comments

Comments
 (0)