Add in-app notitications

This commit is contained in:
dtonon 2026-09-23 10:32:32 +02:00
parent 67d461333c
commit 8695d3e40e
10 changed files with 537 additions and 55 deletions

View file

@ -24,6 +24,10 @@
import { loadRoomAdmins } from "$lib/admins.svelte";
import { seedProfiles } from "$lib/profiles.svelte";
import { startChat } from "$lib/chat.svelte";
import {
startNotifications,
stopNotifications,
} from "$lib/notifications.svelte";
import { resetForumConnection } from "$lib/relay";
import { relayAccess, probeRelayAccess } from "$lib/access.svelte";
import { activeGroup, setActiveGroup } from "$lib/active.svelte";
@ -93,6 +97,15 @@
seedProfiles(auth.user?.pubkey ?? null);
}
// Replies/mentions follow the logged-in user. Keyed on the user rather than
// on loadForum: a restored session resolves its profile after the probe.
$effect(() => {
const pk = auth.user?.pubkey ?? null;
if (relayAccess.state !== "open") return;
if (pk) startNotifications(pk);
else stopNotifications();
});
// Each completed probe that finds the relay open reloads the room views: on
// first load, after a login (private/hidden rooms appear) or logout (they
// vanish), and after joining a members-only relay.
@ -171,9 +184,10 @@
// On mobile a route change should always land on the forum pane, so opening
// a thread or room from the menu never leaves the user stranded on chat.
// A chat message link (#chat-…, e.g. from a notification) opens the chat pane.
$effect(() => {
page.url.pathname;
mobileView = "forum";
mobileView = page.url.hash.startsWith("#chat-") ? "chat" : "forum";
});
</script>

View file

@ -20,9 +20,12 @@
UserPostPage,
} from "$lib/forum/userPosts";
import Meta from "$lib/components/Meta.svelte";
import Notifications from "$lib/components/Notifications.svelte";
import { auth } from "$lib/auth.svelte";
import { summarize } from "$lib/seo";
const pubkey = $derived<string | null>(page.data.pubkey ?? null);
const isOwn = $derived(!!pubkey && auth.user?.pubkey === pubkey);
$effect(() => {
if (!pubkey) return;
@ -240,6 +243,10 @@
{/if}
</div>
{#if isOwn}
<Notifications />
{/if}
<div class="mt-10 grid gap-10 md:grid-cols-2 md:gap-8">
<section aria-labelledby="profile-discussions">
<h2