about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/contexts.js
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2017-11-26 09:45:17 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-11-26 01:45:17 +0100
commitfd87e5a53bcaafb886a675c76e9256015e9db897 (patch)
tree0bf67a28925ad8f3d08d4060ba65d6e6aee08f99 /app/javascript/mastodon/reducers/contexts.js
parent57fe4102ea0f94cd451b440d4b23d9c11d91b49f (diff)
Do not filter the status collection after muting and blocking (#5815)
Filtering the status collection wipes out even the profiles of muted and
blocked accounts. However, the behavior is inconsistent with the server-
side behavior.
Diffstat (limited to 'app/javascript/mastodon/reducers/contexts.js')
-rw-r--r--app/javascript/mastodon/reducers/contexts.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/javascript/mastodon/reducers/contexts.js b/app/javascript/mastodon/reducers/contexts.js
index 64d584a01..fe8308d0c 100644
--- a/app/javascript/mastodon/reducers/contexts.js
+++ b/app/javascript/mastodon/reducers/contexts.js
@@ -1,3 +1,7 @@
+import {
+  ACCOUNT_BLOCK_SUCCESS,
+  ACCOUNT_MUTE_SUCCESS,
+} from '../actions/accounts';
 import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
 import { TIMELINE_DELETE, TIMELINE_CONTEXT_UPDATE } from '../actions/timelines';
 import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
@@ -31,6 +35,12 @@ const deleteFromContexts = (state, id) => {
   return state;
 };
 
+const filterContexts = (state, relationship) => {
+  return state.map(
+    statuses => statuses.filter(
+      status => status.get('account') !== relationship.id));
+};
+
 const updateContext = (state, status, references) => {
   return state.update('descendants', map => {
     references.forEach(parentId => {
@@ -49,6 +59,9 @@ const updateContext = (state, status, references) => {
 
 export default function contexts(state = initialState, action) {
   switch(action.type) {
+  case ACCOUNT_BLOCK_SUCCESS:
+  case ACCOUNT_MUTE_SUCCESS:
+    return filterContexts(state, action.relationship);
   case CONTEXT_FETCH_SUCCESS:
     return normalizeContext(state, action.id, action.ancestors, action.descendants);
   case TIMELINE_DELETE: