diff options
author | prplecake <me@prplecake.com> | 2022-07-30 20:00:00 -0500 |
---|---|---|
committer | prplecake <me@prplecake.com> | 2022-07-30 20:00:00 -0500 |
commit | 991349e6e27f90b671c7892cfbfc74c5a1300f8b (patch) | |
tree | 419fed9f14f7c9aeafc72e1b2e3da381dd8b56bc /app/javascript/flavours/glitch/reducers/tags.js | |
parent | bcb958c2646e8a92b6973016ccd735012e13904c (diff) |
[Glitch] Add ability to follow hashtags in web UI
Diffstat (limited to 'app/javascript/flavours/glitch/reducers/tags.js')
-rw-r--r-- | app/javascript/flavours/glitch/reducers/tags.js | 25 |
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; + } +}; |