about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/relationships.js
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-03-30 12:38:00 +0200
committerEugen Rochko <eugen@zeonfederated.com>2018-03-30 12:38:00 +0200
commita6c129ddbdaaa84bc631d85eb248fb5a9fa7eb96 (patch)
treee086d17c19330bb475595ef27e7e9f471968b810 /app/javascript/mastodon/reducers/relationships.js
parent47cee7cc8e47471b372630cd28d50c6284aad8b3 (diff)
Add some UI for user-defined domain blocks (#6628)
* Keep list of blocked domains

Might be overkill, but I'm trying to follow the same logic as for blocked users

* Add basic domain block UI

* Add the domain blocks UI to Getting Started

* Fix undefined URL in `fetchDomainBlocks`

* Update all known users' domain_blocking relationship instead of just one's
Diffstat (limited to 'app/javascript/mastodon/reducers/relationships.js')
-rw-r--r--app/javascript/mastodon/reducers/relationships.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/javascript/mastodon/reducers/relationships.js b/app/javascript/mastodon/reducers/relationships.js
index c7b04a668..d1caabc1c 100644
--- a/app/javascript/mastodon/reducers/relationships.js
+++ b/app/javascript/mastodon/reducers/relationships.js
@@ -23,6 +23,14 @@ const normalizeRelationships = (state, relationships) => {
   return state;
 };
 
+const setDomainBlocking = (state, accounts, blocking) => {
+  return state.withMutations(map => {
+    accounts.forEach(id => {
+      map.setIn([id, 'domain_blocking'], blocking);
+    });
+  });
+};
+
 const initialState = ImmutableMap();
 
 export default function relationships(state = initialState, action) {
@@ -37,9 +45,9 @@ export default function relationships(state = initialState, action) {
   case RELATIONSHIPS_FETCH_SUCCESS:
     return normalizeRelationships(state, action.relationships);
   case DOMAIN_BLOCK_SUCCESS:
-    return state.setIn([action.accountId, 'domain_blocking'], true);
+    return setDomainBlocking(state, action.accounts, true);
   case DOMAIN_UNBLOCK_SUCCESS:
-    return state.setIn([action.accountId, 'domain_blocking'], false);
+    return setDomainBlocking(state, action.accounts, false);
   default:
     return state;
   }