about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/reducers/notifications.js
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-10-13 08:55:00 +0200
committerGitHub <noreply@github.com>2022-10-13 08:55:00 +0200
commit27a2edcb7925f7c82a50d2df983ba4c51d2cb2c1 (patch)
tree1462d875d994a882e82062142ee78a6da1356143 /app/javascript/flavours/glitch/reducers/notifications.js
parent2bb443c7d5a28d0d206fc57ad775c2864072e04c (diff)
Fix issues with notification cleaning mode when there is a disconnection gap (#1867)
Diffstat (limited to 'app/javascript/flavours/glitch/reducers/notifications.js')
-rw-r--r--app/javascript/flavours/glitch/reducers/notifications.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/javascript/flavours/glitch/reducers/notifications.js b/app/javascript/flavours/glitch/reducers/notifications.js
index 1b593b128..0da5ac457 100644
--- a/app/javascript/flavours/glitch/reducers/notifications.js
+++ b/app/javascript/flavours/glitch/reducers/notifications.js
@@ -162,7 +162,9 @@ const deleteByStatus = (state, statusId) => {
 
 const markForDelete = (state, notificationId, yes) => {
   return state.update('items', list => list.map(item => {
-    if(item.get('id') === notificationId) {
+    if (item === null) {
+      return null;
+    } else if(item.get('id') === notificationId) {
       return item.set('markedForDelete', yes);
     } else {
       return item;
@@ -172,7 +174,9 @@ const markForDelete = (state, notificationId, yes) => {
 
 const markAllForDelete = (state, yes) => {
   return state.update('items', list => list.map(item => {
-    if(yes !== null) {
+    if (item === null) {
+      return null;
+    } else if(yes !== null) {
       return item.set('markedForDelete', yes);
     } else {
       return item.set('markedForDelete', !item.get('markedForDelete'));
@@ -181,11 +185,11 @@ const markAllForDelete = (state, yes) => {
 };
 
 const unmarkAllForDelete = (state) => {
-  return state.update('items', list => list.map(item => item.set('markedForDelete', false)));
+  return state.update('items', list => list.map(item => item === null ? item : item.set('markedForDelete', false)));
 };
 
 const deleteMarkedNotifs = (state) => {
-  return state.update('items', list => list.filterNot(item => item.get('markedForDelete')));
+  return state.update('items', list => list.filterNot(item => item === null ? item : item.get('markedForDelete')));
 };
 
 const updateMounted = (state) => {