2023-05-23 11:15:17 -04:00
|
|
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
|
|
|
|
2022-07-22 09:52:06 -04:00
|
|
|
import {
|
|
|
|
HASHTAG_FETCH_SUCCESS,
|
|
|
|
HASHTAG_FOLLOW_REQUEST,
|
|
|
|
HASHTAG_FOLLOW_FAIL,
|
|
|
|
HASHTAG_UNFOLLOW_REQUEST,
|
|
|
|
HASHTAG_UNFOLLOW_FAIL,
|
|
|
|
} from 'mastodon/actions/tags';
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2022-12-18 10:51:37 -05:00
|
|
|
}
|