diff options
Diffstat (limited to 'app/javascript/flavours/glitch/reducers')
-rw-r--r-- | app/javascript/flavours/glitch/reducers/index.js | 2 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/reducers/tags.js | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/reducers/index.js b/app/javascript/flavours/glitch/reducers/index.js index b8aad9fad..991b4aa79 100644 --- a/app/javascript/flavours/glitch/reducers/index.js +++ b/app/javascript/flavours/glitch/reducers/index.js @@ -41,6 +41,7 @@ import account_notes from './account_notes'; import picture_in_picture from './picture_in_picture'; import accounts_map from './accounts_map'; import history from './history'; +import tags from './tags'; const reducers = { announcements, @@ -85,6 +86,7 @@ const reducers = { account_notes, picture_in_picture, history, + tags, }; export default combineReducers(reducers); 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; + } +}; |