Browse Source

Fix report dialog crashing when a toot gets deleted

Fixes #1155
Thibaut Girka 1 week ago
parent
commit
0baaee495f
1 changed files with 13 additions and 0 deletions
  1. 13
    0
      app/javascript/flavours/glitch/reducers/reports.js

+ 13
- 0
app/javascript/flavours/glitch/reducers/reports.js View File

@@ -8,6 +8,9 @@ import {
8 8
   REPORT_COMMENT_CHANGE,
9 9
   REPORT_FORWARD_CHANGE,
10 10
 } from 'flavours/glitch/actions/reports';
11
+import {
12
+  TIMELINE_DELETE,
13
+} from 'flavours/glitch/actions/timelines';
11 14
 import { Map as ImmutableMap, Set as ImmutableSet } from 'immutable';
12 15
 
13 16
 const initialState = ImmutableMap({
@@ -20,6 +23,14 @@ const initialState = ImmutableMap({
20 23
   }),
21 24
 });
22 25
 
26
+const deleteStatus = (state, id, references) => {
27
+  references.forEach(ref => {
28
+    state = deleteStatus(state, ref[0], []);
29
+  });
30
+
31
+  return state.updateIn(['new', 'status_ids'], ImmutableSet(), set => set.remove(id));
32
+};
33
+
23 34
 export default function reports(state = initialState, action) {
24 35
   switch(action.type) {
25 36
   case REPORT_INIT:
@@ -58,6 +69,8 @@ export default function reports(state = initialState, action) {
58 69
       map.setIn(['new', 'comment'], '');
59 70
       map.setIn(['new', 'isSubmitting'], false);
60 71
     });
72
+  case TIMELINE_DELETE:
73
+    return deleteStatus(state, action.id, action.references);
61 74
   default:
62 75
     return state;
63 76
   }

Loading…
Cancel
Save