Fix unlike counter, fixes #107
This commit is contained in:
parent
817063fd14
commit
d78dd971c0
@ -19,7 +19,7 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
|
|||||||
|
|
||||||
UnfavouriteWorker.perform_async(current_user.account_id, @status.id)
|
UnfavouriteWorker.perform_async(current_user.account_id, @status.id)
|
||||||
|
|
||||||
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, favourites_map: @favourites_map)
|
render json: @status, serializer: REST::StatusSerializer, unfavourite: true, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, favourites_map: @favourites_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
REBLOG_FAIL,
|
REBLOG_FAIL,
|
||||||
FAVORITE_REQUEST,
|
FAVORITE_REQUEST,
|
||||||
FAVORITE_FAIL,
|
FAVORITE_FAIL,
|
||||||
|
UNFAVORITE_REQUEST,
|
||||||
} from '../actions/interactions';
|
} from '../actions/interactions';
|
||||||
import {
|
import {
|
||||||
STATUS_MUTE_SUCCESS,
|
STATUS_MUTE_SUCCESS,
|
||||||
@ -39,6 +40,8 @@ export default function statuses(state = initialState, action) {
|
|||||||
return state.setIn([action.status.get('id'), 'favourited'], true);
|
return state.setIn([action.status.get('id'), 'favourited'], true);
|
||||||
case FAVORITE_FAIL:
|
case FAVORITE_FAIL:
|
||||||
return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'favourited'], false);
|
return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'favourited'], false);
|
||||||
|
case UNFAVORITE_REQUEST:
|
||||||
|
return state.setIn([action.status.get('id'), 'favourited'], false);
|
||||||
case REBLOG_REQUEST:
|
case REBLOG_REQUEST:
|
||||||
return state.setIn([action.status.get('id'), 'reblogged'], true);
|
return state.setIn([action.status.get('id'), 'reblogged'], true);
|
||||||
case REBLOG_FAIL:
|
case REBLOG_FAIL:
|
||||||
|
@ -83,6 +83,16 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def favourites_count
|
||||||
|
if instance_options && instance_options[:unfavourite]
|
||||||
|
# Decrement counter
|
||||||
|
# https://github.com/tootsuite/mastodon/issues/3166
|
||||||
|
object.favourites_count - 1
|
||||||
|
else
|
||||||
|
object.favourites_count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def reblogged
|
def reblogged
|
||||||
if instance_options && instance_options[:relationships]
|
if instance_options && instance_options[:relationships]
|
||||||
instance_options[:relationships].reblogs_map[object.id] || false
|
instance_options[:relationships].reblogs_map[object.id] || false
|
||||||
|
Loading…
Reference in New Issue
Block a user