From c2546941772d25d46f0f1f0223497b43eee30e84 Mon Sep 17 00:00:00 2001 From: userAdityaa Date: Tue, 19 May 2026 19:51:35 +0530 Subject: [PATCH] feat: show unread chat badges during video-only voice calls --- src/app/util/notifications.ts | 22 ++++++++++++++++++---- src/routes/spaces/[relay]/[h]/+page.svelte | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/app/util/notifications.ts b/src/app/util/notifications.ts index 605c3c48..0bc5cb3c 100644 --- a/src/app/util/notifications.ts +++ b/src/app/util/notifications.ts @@ -1,4 +1,4 @@ -import {derived} from "svelte/store" +import {derived, get, writable} from "svelte/store" import {Badge} from "@capawesome/capacitor-badge" import {synced, throttled, withGetter} from "@welshman/store" import {pubkey, tracker, repository, relaysByUrl} from "@welshman/app" @@ -36,6 +36,9 @@ export const deriveChecked = (key: string) => derived(checked, prop(key) export const setChecked = (key: string) => checked.update(assoc(key, now())) +/** Room path while video call UI hides chat; checked + badge stay active until chat is shown. */ +export const deferredRoomPath = writable(undefined) + export const syncChecked = () => { let prev = "" @@ -57,8 +60,11 @@ export const syncChecked = () => { // Set checked when we visit a given page - but delay it a tad setTimeout(() => { + const defer = get(deferredRoomPath) + checked.update($checked => { for (const path of getPaths($page.url.pathname)) { + if (defer && path === defer) continue $checked[path] = now() } @@ -151,9 +157,17 @@ export const allNotifications = derived( }, ) -export const notifications = derived([page, allNotifications], ([$page, $allNotifications]) => { - return new Set([...$allNotifications].filter(p => !$page.url.pathname.startsWith(p))) -}) +export const notifications = derived( + [page, allNotifications, deferredRoomPath], + ([$page, $allNotifications, $deferredRoomPath]) => + new Set( + [...$allNotifications].filter(p => { + if (!$page.url.pathname.startsWith(p)) return true + if ($deferredRoomPath && p === $deferredRoomPath) return true + return false + }), + ), +) // Badges diff --git a/src/routes/spaces/[relay]/[h]/+page.svelte b/src/routes/spaces/[relay]/[h]/+page.svelte index 54c7df66..cec4c73e 100644 --- a/src/routes/spaces/[relay]/[h]/+page.svelte +++ b/src/routes/spaces/[relay]/[h]/+page.svelte @@ -1,5 +1,5 @@