about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/domain_lists.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/domain_lists.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/domain_lists.js')
-rw-r--r--app/javascript/mastodon/reducers/domain_lists.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/javascript/mastodon/reducers/domain_lists.js b/app/javascript/mastodon/reducers/domain_lists.js
new file mode 100644
index 000000000..a9e3519f3
--- /dev/null
+++ b/app/javascript/mastodon/reducers/domain_lists.js
@@ -0,0 +1,23 @@
+import {
+  DOMAIN_BLOCKS_FETCH_SUCCESS,
+  DOMAIN_BLOCKS_EXPAND_SUCCESS,
+  DOMAIN_UNBLOCK_SUCCESS,
+} from '../actions/domain_blocks';
+import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
+
+const initialState = ImmutableMap({
+  blocks: ImmutableMap(),
+});
+
+export default function domainLists(state = initialState, action) {
+  switch(action.type) {
+  case DOMAIN_BLOCKS_FETCH_SUCCESS:
+    return state.setIn(['blocks', 'items'], ImmutableOrderedSet(action.domains)).setIn(['blocks', 'next'], action.next);
+  case DOMAIN_BLOCKS_EXPAND_SUCCESS:
+    return state.updateIn(['blocks', 'items'], set => set.union(action.domains)).setIn(['blocks', 'next'], action.next);
+  case DOMAIN_UNBLOCK_SUCCESS:
+    return state.updateIn(['blocks', 'items'], set => set.delete(action.domain));
+  default:
+    return state;
+  }
+};