diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-07-22 15:52:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-22 15:52:06 +0200 |
commit | 9608e720a4e5f977c0e2db0de7b264574b0ddeac (patch) | |
tree | 0b83743498b8c8ffdfd24a4a2861e30d11413277 /app/javascript/mastodon/reducers/tags.js | |
parent | 76ff45230630c32dd01fd45c89557e092a81b27f (diff) |
Add ability to follow hashtags in web UI (#18862)
Diffstat (limited to 'app/javascript/mastodon/reducers/tags.js')
-rw-r--r-- | app/javascript/mastodon/reducers/tags.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/javascript/mastodon/reducers/tags.js b/app/javascript/mastodon/reducers/tags.js new file mode 100644 index 000000000..d24098e39 --- /dev/null +++ b/app/javascript/mastodon/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; + } +}; |