diff --git a/frontend/src/components/FriendsPanel.svelte b/frontend/src/components/FriendsPanel.svelte index 7985f03..1f1cd53 100644 --- a/frontend/src/components/FriendsPanel.svelte +++ b/frontend/src/components/FriendsPanel.svelte @@ -88,6 +88,21 @@ } } + // "Legg til som venn tilbake" — for an incoming entry where I haven't + // already added them. Goes through the same addFriend API as the form + // above. If the user hasn't set a username (rare — incoming implies they + // added someone, which requires THE OTHER PARTY's username, not theirs) + // we hide the button instead of erroring. + async function addBack(f: FriendEntry) { + if (!f.username) return; + try { + const added = await api.addFriend({ username: f.username }); + outgoing = [added, ...outgoing.filter((o) => o.user_id !== added.user_id)]; + } catch { + loadError = 'Klarte ikke å legge til venn.'; + } + } + async function block(e: FriendEntry) { if (!confirm(`Blokkere ${displayName(e)}? De vil ikke lenger se aktiviteter du deler med venner.`)) return; try { @@ -155,13 +170,22 @@

Ingen har lagt deg til ennå.

{/if} {#each incoming as f (f.user_id)} + {@const alreadyFriend = outgoing.some((o) => o.user_id === f.user_id)}
-
+
{displayName(f)} {#if f.username}· @{f.username}{/if} + {#if alreadyFriend}(gjensidig){/if} - +
+ {#if !alreadyFriend && f.username} + + {/if} + +
{/each} diff --git a/frontend/src/components/Profile.svelte b/frontend/src/components/Profile.svelte index 30a7f5b..28fee8d 100644 --- a/frontend/src/components/Profile.svelte +++ b/frontend/src/components/Profile.svelte @@ -386,10 +386,13 @@
{#if inv.claimed_at} - Brukt - {#if inv.claimed_by_display} - av {inv.claimed_by_display} · {formatDate(inv.claimed_at)} - {/if} + + {#if inv.claimed_by_display} + ✓ Mottatt og tatt i bruk av {inv.claimed_by_display} · {formatDate(inv.claimed_at)} + {:else} + ✓ Mottatt og tatt i bruk · {formatDate(inv.claimed_at)} + {/if} + {:else}