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
committerEugen Rochko <eugen@zeonfederated.com>2019-10-24 22:49:45 +0200
commita9530e29a2813ed8cf4c8f13fe60dd9fad245466 (patch)
treed52784b194eae5a27f999980b37067ae6bfc18da /app/javascript
parent15c192ce4053d77183538efa1740ba5bec71082e (diff)
Unliking a post updates like count on front end (#12140)
* return the new favourites_count
when unfavouriting a status

* Remove trailing whitespace

* revert changes to favourites_controller

* Decrease favourites_count through statuses reducer

* styling fix

* Fix missing trailing comma
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/reducers/statuses.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/javascript/mastodon/reducers/statuses.js b/app/javascript/mastodon/reducers/statuses.js
index 885cc221c..372673bc0 100644
--- a/app/javascript/mastodon/reducers/statuses.js
+++ b/app/javascript/mastodon/reducers/statuses.js
@@ -3,6 +3,7 @@ import {
   REBLOG_FAIL,
   FAVOURITE_REQUEST,
   FAVOURITE_FAIL,
+  UNFAVOURITE_SUCCESS,
 } from '../actions/interactions';
 import {
   STATUS_MUTE_SUCCESS,
@@ -37,6 +38,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 REBLOG_REQUEST: