From 2bd20f229d2999873ef68872816459c7f681fdae Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Tue, 18 Mar 2025 14:37:58 +0530 Subject: [PATCH] feat: use better counts --- .../widgets/conversation/MessagesView.vue | 18 +++++++++++------- .../dashboard/i18n/locale/en/conversation.json | 3 +++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue index 2d123fac4..227d19022 100644 --- a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue +++ b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue @@ -238,13 +238,17 @@ export default { return this.currentChat.unread_count || 0; }, unreadMessageLabel() { - const count = - this.unreadMessageCount > 9 ? '9+' : this.unreadMessageCount; - const label = - this.unreadMessageCount > 1 - ? this.$t('CONVERSATION.UNREAD_MESSAGES') - : this.$t('CONVERSATION.UNREAD_MESSAGE'); - return `${count} ${label}`; + if (this.unreadMessageCount <= 1) { + return this.$t('CONVERSATION.SINGLE_UNREAD_MESSAGE'); + } + + if (this.unreadMessageCount > 9) { + return this.$t('CONVERSATION.UNREAD_COUNT_OVERFLOW'); + } + + return this.$t('CONVERSATION.UNREAD_COUNT', { + count: this.unreadMessageCount, + }); }, isInstagramDM() { return this.conversationType === 'instagram_direct_message'; diff --git a/app/javascript/dashboard/i18n/locale/en/conversation.json b/app/javascript/dashboard/i18n/locale/en/conversation.json index 2847f4821..c4a5a36f1 100644 --- a/app/javascript/dashboard/i18n/locale/en/conversation.json +++ b/app/javascript/dashboard/i18n/locale/en/conversation.json @@ -25,6 +25,9 @@ "PLACEHOLDER": "Type any text to search messages", "NO_MATCHING_RESULTS": "No results found." }, + "UNREAD_COUNT": "{count} Unread Messages", + "UNREAD_COUNT_OVERFLOW": "9+ Unread Messages", + "SINGLE_UNREAD_MESSAGE": "1 Unread Message", "UNREAD_MESSAGES": "Unread Messages", "UNREAD_MESSAGE": "Unread Message", "CLICK_HERE": "Click here",