Show "Seen on" in profiles

This commit is contained in:
dtonon 2026-08-27 21:04:04 +01:00
parent 9950c4337a
commit 7b80afbd6c

View file

@ -2,6 +2,7 @@
import { page } from "$app/state"; import { page } from "$app/state";
import { MODE } from "$lib/config"; import { MODE } from "$lib/config";
import { getGroupName } from "$lib/group.svelte"; import { getGroupName } from "$lib/group.svelte";
import { groupsStore } from "$lib/groups.svelte";
import { import {
profileStore, profileStore,
ensureProfile, ensureProfile,
@ -44,6 +45,15 @@
: (page.data.posts ?? null), : (page.data.posts ?? null),
); );
// Rooms the loaded posts come from, in the rooms list order (full mode).
const seenOn = $derived.by(() => {
if (MODE !== "full" || !posts) return [];
const ids = new Set(
[...posts.roots.items, ...posts.replies.items].map((p) => p.groupId),
);
return groupsStore.list.filter((g) => ids.has(g.id));
});
const npub = $derived(entry?.npub ?? page.params.id ?? ""); const npub = $derived(entry?.npub ?? page.params.id ?? "");
const name = $derived( const name = $derived(
entry?.displayName || entry?.name || `${npub.slice(0, 12)}…`, entry?.displayName || entry?.name || `${npub.slice(0, 12)}…`,
@ -202,6 +212,16 @@
View on njump ↗ View on njump ↗
</a> </a>
</div> </div>
{#if seenOn.length > 0}
<p class="mt-2 text-neutral-500 dark:text-neutral-400">
<span class="text-neutral-400 dark:text-neutral-500">Seen on:</span>
{#each seenOn as r, i (r.id)}<a
href="/room/{r.id}"
class="text-accent hover:underline">{r.name}</a
>{i < seenOn.length - 1 ? ", " : ""}{/each}
</p>
{/if}
</div> </div>
{#if entry?.picture} {#if entry?.picture}