Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add favourited toot to favourites column #4562

Merged
merged 2 commits into from Aug 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/javascript/mastodon/reducers/status_lists.js
Expand Up @@ -3,6 +3,7 @@ import {
FAVOURITED_STATUSES_EXPAND_SUCCESS,
} from '../actions/favourites';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import { FAVOURITE_SUCCESS } from '../actions/interactions';

const initialState = ImmutableMap({
favourites: ImmutableMap({
Expand All @@ -27,12 +28,20 @@ const appendToList = (state, listType, statuses, next) => {
}));
};

const prependOneToList = (state, listType, status) => {
return state.update(listType, listMap => listMap.withMutations(map => {
map.set('items', map.get('items').unshift(status.get('id')));
}));
};

export default function statusLists(state = initialState, action) {
switch(action.type) {
case FAVOURITED_STATUSES_FETCH_SUCCESS:
return normalizeList(state, 'favourites', action.statuses, action.next);
case FAVOURITED_STATUSES_EXPAND_SUCCESS:
return appendToList(state, 'favourites', action.statuses, action.next);
case FAVOURITE_SUCCESS:
return prependOneToList(state, 'favourites', action.status);
default:
return state;
}
Expand Down