[Glitch] Unliking a post updates like count on front end

Port 092103cf4e to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
lolsob-rspec
Nima Boscarino 2019-10-24 13:49:45 -07:00 committed by Thibaut Girka
parent f94af5dc67
commit 8ef3379c6d
1 changed files with 4 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import {
REBLOG_FAIL,
FAVOURITE_REQUEST,
FAVOURITE_FAIL,
UNFAVOURITE_SUCCESS,
BOOKMARK_REQUEST,
BOOKMARK_FAIL,
} from 'flavours/glitch/actions/interactions';
@ -39,6 +40,9 @@ export default function statuses(state = initialState, action) {
return importStatuses(state, action.statuses);
case FAVOURITE_REQUEST:
return state.setIn([action.status.get('id'), 'favourited'], true);
case UNFAVOURITE_SUCCESS:
const favouritesCount = action.status.get('favourites_count');
return state.setIn([action.status.get('id'), 'favourites_count'], favouritesCount - 1);
case FAVOURITE_FAIL:
return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'favourited'], false);
case BOOKMARK_REQUEST: