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)}