about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/reducers/tags.js
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-08-13 00:09:33 -0500
committerStarfall <us@starfall.systems>2022-08-13 00:09:33 -0500
commit3871928aa4f660cdf1a0c451ac3396052b59ddea (patch)
tree4221292f7eb1e446d60b6a0fc1bb4e603dc6a750 /app/javascript/flavours/glitch/reducers/tags.js
parent5b9419060d79eda85c40a12c567dd0e1e44a7ecb (diff)
parent3f15326a05a926e9f001800a48ac2addbd3aa833 (diff)
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'app/javascript/flavours/glitch/reducers/tags.js')
-rw-r--r--app/javascript/flavours/glitch/reducers/tags.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/reducers/tags.js b/app/javascript/flavours/glitch/reducers/tags.js
new file mode 100644
index 000000000..d24098e39
--- /dev/null
+++ b/app/javascript/flavours/glitch/reducers/tags.js
@@ -0,0 +1,25 @@
+import {
+  HASHTAG_FETCH_SUCCESS,
+  HASHTAG_FOLLOW_REQUEST,
+  HASHTAG_FOLLOW_FAIL,
+  HASHTAG_UNFOLLOW_REQUEST,
+  HASHTAG_UNFOLLOW_FAIL,
+} from 'mastodon/actions/tags';
+import { Map as ImmutableMap, fromJS } from 'immutable';
+
+const initialState = ImmutableMap();
+
+export default function tags(state = initialState, action) {
+  switch(action.type) {
+  case HASHTAG_FETCH_SUCCESS:
+    return state.set(action.name, fromJS(action.tag));
+  case HASHTAG_FOLLOW_REQUEST:
+  case HASHTAG_UNFOLLOW_FAIL:
+    return state.setIn([action.name, 'following'], true);
+  case HASHTAG_FOLLOW_FAIL:
+  case HASHTAG_UNFOLLOW_REQUEST:
+    return state.setIn([action.name, 'following'], false);
+  default:
+    return state;
+  }
+};