From 1bbc2eca2491d955e6da36d9a84f58e2e5ee3fcf Mon Sep 17 00:00:00 2001 From: Shinigami Date: Fri, 16 Feb 2024 17:48:53 +0100 Subject: [PATCH] fix: notification badge (#2592) Co-authored-by: Ayo --- composables/masto/notification.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/composables/masto/notification.ts b/composables/masto/notification.ts index 8577b252..4797a543 100644 --- a/composables/masto/notification.ts +++ b/composables/masto/notification.ts @@ -10,8 +10,10 @@ export function useNotifications() { async function clearNotifications() { if (!id || !notifications[id]) return + const lastReadId = notifications[id]![1][0] notifications[id]![1] = [] + if (lastReadId) { await client.v1.markers.create({ notifications: { lastReadId }, @@ -30,11 +32,11 @@ export function useNotifications() { if (!isHydrated.value || !id || notifications[id] !== undefined || !currentUser.value?.token) return - let resolveStream + let resolveStream: ((value: mastodon.streaming.Subscription | PromiseLike) => void) | undefined const streamPromise = new Promise(resolve => resolveStream = resolve) notifications[id] = [streamPromise, []] - await until($$(streamingClient)).toBe(true) + await until($$(streamingClient)).toBeTruthy() const stream = streamingClient!.user.subscribe() resolveStream!(stream) @@ -43,6 +45,7 @@ export function useNotifications() { const position = await client.v1.markers.fetch({ timeline: ['notifications'] }) const paginator = client.v1.notifications.list({ limit: 30 }) + do { const result = await paginator.next() if (!result.done && result.value.length) {