about summary refs log tree commit diff
path: root/app/javascript/flavours
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-07-10 19:12:51 +0200
committerThibG <thib@sitedethib.com>2019-07-10 19:53:31 +0200
commit0baaee495f83e1b4b5d42196b78aa220256b75ee (patch)
tree81ef7ead802966234bdb6fb434c950acb3bf8df4 /app/javascript/flavours
parentfce885f271f8651702d606406e21677280071e40 (diff)
Fix report dialog crashing when a toot gets deleted
Fixes #1155
Diffstat (limited to 'app/javascript/flavours')
-rw-r--r--app/javascript/flavours/glitch/reducers/reports.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/reducers/reports.js b/app/javascript/flavours/glitch/reducers/reports.js
index fdcfb14a0..1f7f3f273 100644
--- a/app/javascript/flavours/glitch/reducers/reports.js
+++ b/app/javascript/flavours/glitch/reducers/reports.js
@@ -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;
   }