about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorNima Boscarino <nima.boscarino@gmail.com>2019-10-24 13:49:45 -0700
committerThibaut Girka <thib@sitedethib.com>2019-10-27 14:44:27 +0100
commitebe34ed529b232d697110afc42af5a1d893ad544 (patch)
tree88c07831b08a3b973f1876d19cb05a0277b2fe27 /app/javascript
parent957eb4241aa361ff2385992283512f27fa8fbc97 (diff)
[Glitch] Unliking a post updates like count on front end
Port a9530e29a2813ed8cf4c8f13fe60dd9fad245466 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/flavours/glitch/reducers/statuses.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/reducers/statuses.js b/app/javascript/flavours/glitch/reducers/statuses.js
index 96c9c6d04..ee8ac929d 100644
--- a/app/javascript/flavours/glitch/reducers/statuses.js
+++ b/app/javascript/flavours/glitch/reducers/statuses.js
@@ -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: