Add ability to follow hashtags in web UI (#18862)

This commit is contained in:
Eugen Rochko
2022-07-22 15:52:06 +02:00
committed by GitHub
parent 76ff452306
commit 9608e720a4
4 changed files with 188 additions and 18 deletions

View File

@ -39,6 +39,7 @@ import markers from './markers';
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,
@ -81,6 +82,7 @@ const reducers = {
markers,
picture_in_picture,
history,
tags,
};
export default combineReducers(reducers);

View File

@ -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;
}
};