Update replies/reblogs/favourites count in statuses

This commit is contained in:
niu tech 2023-07-10 20:39:17 +02:00 committed by GitHub
parent bc22b54e4c
commit 85b5bc2098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -122,22 +122,28 @@
store: () => store,
methods: {
toggleFavorite (announce) {
const { originalStatusId, favorited } = this.get()
const { originalStatusId, favorited, originalStatus } = this.get()
const newFavoritedValue = !favorited
/* no await */ setFavorited(originalStatusId, newFavoritedValue)
if (newFavoritedValue) {
this.refs.favoriteIcon.animate(FAVORITE_ANIMATION, CHECKMARK_ANIMATION)
originalStatus.favourites_count++
} else {
originalStatus.favourites_count--
}
if (announce) {
announceAriaLivePolite(newFavoritedValue ? 'intl.favorited' : 'intl.unfavorited')
}
},
reblog (announce) {
const { originalStatusId, reblogged } = this.get()
const { originalStatusId, reblogged, originalStatus } = this.get()
const newRebloggedValue = !reblogged
/* no await */ setReblogged(originalStatusId, newRebloggedValue)
if (newRebloggedValue) {
this.refs.reblogIcon.animate(REBLOG_ANIMATION, CHECKMARK_ANIMATION)
originalStatus.reblogs_count++
} else {
originalStatus.reblogs_count--
}
if (announce) {
announceAriaLivePolite(newRebloggedValue ? 'intl.reblogged' : 'intl.unreblogged')
@ -169,12 +175,14 @@
onPostedStatus (realm, inReplyToUuid) {
const {
originalStatusId,
uuid
uuid,
originalStatus
} = this.get()
if (realm !== originalStatusId ||
inReplyToUuid !== uuid) {
return
}
originalStatus.replies_count++
try {
// return status to the reply button after posting a reply
this.refs.node.querySelector('.status-toolbar-reply-button').focus({ preventScroll: true })