fixup! Added logic to process reply to favorite request and update likes counter accordingly. Should fix some of cases of doubled likes and likes counter not decrementing.

This commit is contained in:
Henry Jameson 2018-08-30 16:27:35 +03:00
parent 1246463f96
commit 507d5bc444
1 changed files with 3 additions and 3 deletions

View File

@ -195,11 +195,11 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
const favoriteStatus = (favorite, counter) => { const favoriteStatus = (favorite, counter) => {
const status = find(allStatuses, { id: toInteger(favorite.in_reply_to_status_id) }) const status = find(allStatuses, { id: toInteger(favorite.in_reply_to_status_id) })
if (status) { if (status) {
status.fave_num += 1
// This is our favorite, so the relevant bit. // This is our favorite, so the relevant bit.
if (favorite.user.id === user.id) { if (favorite.user.id === user.id) {
status.favorited = true status.favorited = true
} else {
status.fave_num += 1
} }
} }
return status return status
@ -234,7 +234,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
'favorite': (favorite) => { 'favorite': (favorite) => {
// Only update if this is a new favorite. // Only update if this is a new favorite.
// Ignore our own favorites because we get info about likes as response to like request // Ignore our own favorites because we get info about likes as response to like request
if (!state.favorites.has(favorite.id) && user.id !== favorite.user.id) { if (!state.favorites.has(favorite.id)) {
state.favorites.add(favorite.id) state.favorites.add(favorite.id)
favoriteStatus(favorite) favoriteStatus(favorite)
} }