]> cat aescling's git repositories - mastodon.git/commitdiff
Add missing null handling in notification reducer (#6930)
authorunarist <m.unarist@gmail.com>
Tue, 27 Mar 2018 11:05:59 +0000 (20:05 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 27 Mar 2018 11:05:59 +0000 (13:05 +0200)
This patch adds null item (i.e. gap) handling on below functions to avoid TypeError.

* `filterNotifications` called on user mute/block
* `deleteByStatus` called on status deletion

app/javascript/mastodon/reducers/notifications.js

index f023984b8fa2e2ba95314f51e2fbd4ed5ac7f0e0..1ac7eb706d140f3e4cf661402af6cd5bbad97376 100644 (file)
@@ -82,7 +82,7 @@ const expandNormalizedNotifications = (state, notifications, next) => {
 };
 
 const filterNotifications = (state, relationship) => {
-  return state.update('items', list => list.filterNot(item => item.get('account') === relationship.id));
+  return state.update('items', list => list.filterNot(item => item !== null && item.get('account') === relationship.id));
 };
 
 const updateTop = (state, top) => {
@@ -94,7 +94,7 @@ const updateTop = (state, top) => {
 };
 
 const deleteByStatus = (state, statusId) => {
-  return state.update('items', list => list.filterNot(item => item.get('status') === statusId));
+  return state.update('items', list => list.filterNot(item => item !== null && item.get('status') === statusId));
 };
 
 export default function notifications(state = initialState, action) {