]> cat aescling's git repositories - mastodon.git/commitdiff
Fix report dialog crashing when a toot gets deleted
authorThibaut Girka <thib@sitedethib.com>
Wed, 10 Jul 2019 17:12:51 +0000 (19:12 +0200)
committerThibG <thib@sitedethib.com>
Wed, 10 Jul 2019 17:53:31 +0000 (19:53 +0200)
Fixes #1155

app/javascript/flavours/glitch/reducers/reports.js

index fdcfb14a087d2e36e4ef68a0e8fd6596bdfa8859..1f7f3f27314c8dc4c67485055eb640ffb79de76b 100644 (file)
@@ -8,6 +8,9 @@ import {
   REPORT_COMMENT_CHANGE,
   REPORT_FORWARD_CHANGE,
 } from 'flavours/glitch/actions/reports';
+import {
+  TIMELINE_DELETE,
+} from 'flavours/glitch/actions/timelines';
 import { Map as ImmutableMap, Set as ImmutableSet } from 'immutable';
 
 const initialState = ImmutableMap({
@@ -20,6 +23,14 @@ const initialState = ImmutableMap({
   }),
 });
 
+const deleteStatus = (state, id, references) => {
+  references.forEach(ref => {
+    state = deleteStatus(state, ref[0], []);
+  });
+
+  return state.updateIn(['new', 'status_ids'], ImmutableSet(), set => set.remove(id));
+};
+
 export default function reports(state = initialState, action) {
   switch(action.type) {
   case REPORT_INIT:
@@ -58,6 +69,8 @@ export default function reports(state = initialState, action) {
       map.setIn(['new', 'comment'], '');
       map.setIn(['new', 'isSubmitting'], false);
     });
+  case TIMELINE_DELETE:
+    return deleteStatus(state, action.id, action.references);
   default:
     return state;
   }