]> cat aescling's git repositories - mastodon.git/commitdiff
Fix issues with notification cleaning mode when there is a disconnection gap (#1867)
authorClaire <claire.github-309c@sitedethib.com>
Thu, 13 Oct 2022 06:55:00 +0000 (08:55 +0200)
committeraescling <aescling+gitlab@cat.family>
Thu, 17 Nov 2022 05:28:26 +0000 (00:28 -0500)
app/javascript/flavours/glitch/reducers/notifications.js

index 1b593b12816ff913bc2ef8519cbf6a63d4f018a1..0da5ac457da1ee58668e3ec5b7d7cc2dc87f7338 100644 (file)
@@ -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) => {