[Glitch] Add ability to follow hashtags in web UI

This commit is contained in:
prplecake
2022-07-30 20:00:00 -05:00
parent bcb958c264
commit 991349e6e2
4 changed files with 185 additions and 16 deletions

View File

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

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