diff options
author | Ondřej Hruška <ondra@ondrovo.com> | 2017-08-09 00:22:26 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-08-09 00:22:26 +0200 |
commit | b1c8a702a457ea04c3800ddb915032a0800a2048 (patch) | |
tree | d521432e24000c138cf8b0fc27a763f271ebb7f9 /app/javascript | |
parent | 820099813fe4ff824b939cc60c690be369997c59 (diff) |
Add favourited toot to favourites column (#4562)
* Add faved toot to faves column * renamed append to prepend for clarity
Diffstat (limited to 'app/javascript')
-rw-r--r-- | app/javascript/mastodon/reducers/status_lists.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/javascript/mastodon/reducers/status_lists.js b/app/javascript/mastodon/reducers/status_lists.js index bbc973302..580cc17d2 100644 --- a/app/javascript/mastodon/reducers/status_lists.js +++ b/app/javascript/mastodon/reducers/status_lists.js @@ -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({ @@ -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; } |