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