[bug] Like/Boost indicator disappears after a few moments #370
Labels
No labels
a11y
Bug
Bug fix
Critical Priority
Documentation
Feature
Feature request
Held for next release cycle
High Priority
Low Priority
Medium Priority
Minor change
Translation/Locale
WIP
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: AkkomaGang/akkoma-fe#370
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version
d304be654f
What were you trying to do and what went wrong?
Had this issue and the first research results here noted down for a while, but didn’t get around to look into how to fix this with the various event dispatches and layers involved here; before I forget i’ll post my findings so far here. Ofc anyone is welcome to to tackle this.
Sometimes when i fav or boost a post, the icon first performs the animation into an activated state but then after a few moments the indicator disappears again. Reloading the page brings the indication back.
Looking through the code it seems like when the button is clicked, the fav/boost is immediately added to the local data and the state activated and at the same time requests to both actually submit the action to the server and to refetch the current number and accounts who faved/boosted the post are submitted.
I’m guessing sometimes the refetch gets processed before the actual action, so when the reply arrives the own action isn’t accounted for yet and subsequently the indicator toggles off again.
Relevant parts of the code:
favorite () {
if (!this.status.favorited) {
this.$store.dispatch('favorite', { id: this.status.id })
} else {
this.$store.dispatch('unfavorite', { id: this.status.id })
}
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
}
'favorite': (favorite) => {
// Only update if this is a new favorite.
// Ignore our own favorites because we get info about likes as response to like request
if (!state.favorites.has(favorite.id)) {
state.favorites.add(favorite.id)
favoriteStatus(favorite)
}
},
Note how it directly adds the own fav to local data; in itself this isn’t necessarily a bad idea as it improves UI responsiveness on slow network — as long as a failure is later properly indicated and a success doesn’t just randomly disappear again
'status.fave_num': function (num) {
// refetch favs when fave_num is changed in any way
if (this.isFocused && this.statusFromGlobalRepository.favoritedBy && this.statusFromGlobalRepository.favoritedBy.length !== num) {
this.$store.dispatch('fetchFavs', this.status.id)
}
},
What did you expect to happen?
Indicator never disappears once activated unless there was an actual issue submitting the action to the server.
I.e.: fetching the new fav/boost count and users should wait until after the initial favourite/boost request finished.
Severity
I can manage
Have you searched for this issue?