From 85b5bc2098c957a71030274f3f563b9148017465 Mon Sep 17 00:00:00 2001 From: niu tech Date: Mon, 10 Jul 2023 20:39:17 +0200 Subject: [PATCH] Update replies/reblogs/favourites count in statuses --- src/routes/_components/status/StatusToolbar.html | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/routes/_components/status/StatusToolbar.html b/src/routes/_components/status/StatusToolbar.html index 509d13f9..aec0dcc5 100644 --- a/src/routes/_components/status/StatusToolbar.html +++ b/src/routes/_components/status/StatusToolbar.html @@ -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 })