From 1a8b54a9aedaeaddfba1f015605f4d2a128fefc1 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Fri, 19 Apr 2024 10:32:05 +0800 Subject: [PATCH 1/2] fix(TopBar): notification count error displaying 999+ issue --- src/components/TopBar/TopBar.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/TopBar/TopBar.vue b/src/components/TopBar/TopBar.vue index 288dc6cb..bafc5d5b 100644 --- a/src/components/TopBar/TopBar.vue +++ b/src/components/TopBar/TopBar.vue @@ -261,8 +261,10 @@ async function getUnreadMessageCount() { if (res.code === 0) { Object.assign(unReadMessage, res.data) Object.entries(unReadMessage).forEach(([key, value]) => { - if (key !== 'up') - unReadMessageCount.value += typeof value === 'number' ? value : 0 + if (key !== 'up') { + if (typeof value === 'number') + unReadMessageCount.value += value + } }) } @@ -271,7 +273,8 @@ async function getUnreadMessageCount() { }) if (res.code === 0) { Object.assign(unReadDm, res.data) - unReadMessageCount.value += unReadDm.follow_unread + if (typeof unReadDm.follow_unread === 'number') + unReadMessageCount.value += unReadDm.follow_unread } } catch (error) { From 591ea2ef77fd44a3f98a1fcf71574891389d3085 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Fri, 19 Apr 2024 10:52:25 +0800 Subject: [PATCH 2/2] fix(TopBar): cannot remove the new moments count immediately (#425) close #425 --- src/components/TopBar/TopBar.vue | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/TopBar/TopBar.vue b/src/components/TopBar/TopBar.vue index bafc5d5b..b20ebba9 100644 --- a/src/components/TopBar/TopBar.vue +++ b/src/components/TopBar/TopBar.vue @@ -126,7 +126,7 @@ watch( if (newVal === oldVal) return - if (!newVal) + if (newVal) getUnreadMessageCount() }, ) @@ -137,7 +137,7 @@ watch( if (newVal === oldVal) return - if (!newVal) + if (newVal) await getTopBarNewMomentsCount() }, ) @@ -293,10 +293,9 @@ async function getTopBarNewMomentsCount() { const res = await browser.runtime.sendMessage({ contentScriptQuery: 'getTopBarNewMomentsCount', }) - newMomentsCount.value = res.data.update_info.item.count - // If moments count > 0 then refresh the key to get the new moments - if (newMomentsCount.value > 0) - momentsPopKey.value = `momentsPop[${Number(new Date())}]` + + if (typeof res.data.update_info.item.count === 'number') + newMomentsCount.value = res.data.update_info.item.count } catch { newMomentsCount.value = 0