From 6ecd618bcef9c61e3029234cb7e06564317aa334 Mon Sep 17 00:00:00 2001 From: dtonon Date: Thu, 13 Aug 2026 22:54:26 +0100 Subject: [PATCH] Join relay and group dynamically, dropping PUBLIC_JOINCODE --- .env.example | 1 - src/lib/components/ChatSidebar.svelte | 9 +- src/lib/components/DiscussionsFeed.svelte | 30 +- src/lib/components/JoinModal.svelte | 92 +++-- src/lib/config.ts | 1 - src/lib/group.svelte.ts | 9 + src/lib/join.svelte.ts | 446 +++++++++++++++------- src/lib/relay.ts | 34 +- src/routes/thread/[id]/+page.svelte | 9 +- 9 files changed, 453 insertions(+), 178 deletions(-) diff --git a/.env.example b/.env.example index 570c9e7..ba17862 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,6 @@ PUBLIC_RELAY_URL=ws://localhost:3334 # required — NIP-29 relay hosting the g PUBLIC_MODE=simple # simple | full (single forum vs. many rooms) PUBLIC_GROUP_ID=mygrouprandomid # required in simple mode; the single forum's group id (ignored in full mode) PUBLIC_TITLE= # top-bar title; empty falls back to the group name -PUBLIC_JOINCODE=no # yes | no — show an invite-code field when a join is rejected PUBLIC_SEARCH=no # yes | no — enable the search box (requires a relay with NIP-50 support) PUBLIC_LABELS= # comma-separated discussion labels (e.g., bug,feature,question) PUBLIC_BLOSSOM_URL= # Blossom server URL for uploads (e.g., https://blossom.primal.net) diff --git a/src/lib/components/ChatSidebar.svelte b/src/lib/components/ChatSidebar.svelte index 6551b79..8d65181 100644 --- a/src/lib/components/ChatSidebar.svelte +++ b/src/lib/components/ChatSidebar.svelte @@ -15,9 +15,9 @@ } from "$lib/moderation.svelte"; import { withJoin, + joinState, membershipOf, ensureMembershipChecked, - openJoinModal, } from "$lib/join.svelte"; import { activeGroup } from "$lib/active.svelte"; import type { NostrUser } from "@nostr/gadgets/metadata"; @@ -76,7 +76,7 @@ }); function onJoinToChat() { - openJoinModal(activeGroup.id, () => tick().then(() => inputEl?.focus())); + withJoin(activeGroup.id, () => tick().then(() => inputEl?.focus())); } function requestDeleteMessage(msg: ChatMessageData) { @@ -486,9 +486,10 @@ {:else if joinToChat} {:else}
diff --git a/src/lib/components/DiscussionsFeed.svelte b/src/lib/components/DiscussionsFeed.svelte index d039217..e914916 100644 --- a/src/lib/components/DiscussionsFeed.svelte +++ b/src/lib/components/DiscussionsFeed.svelte @@ -18,7 +18,8 @@ import { membershipOf, ensureMembershipChecked, - openJoinModal, + withJoin, + joinState, } from "$lib/join.svelte"; import { sortPref } from "$lib/sort.svelte"; import { page } from "$app/state"; @@ -71,12 +72,7 @@ openLogin(onNewTopic); return; } - await ensureMembershipChecked(groupId); - if (membershipOf(groupId) !== "member") { - openJoinModal(groupId, openDraft); - return; - } - openDraft(); + await withJoin(groupId, openDraft); } function onPrivateJoin() { @@ -84,7 +80,7 @@ openLogin(); return; } - openJoinModal(groupId, () => loadThreads(groupId, sort)); + withJoin(groupId, () => loadThreads(groupId, sort)); } function relativeTime(ts: number): string { @@ -138,9 +134,14 @@
@@ -165,9 +166,14 @@

{:else} diff --git a/src/lib/components/JoinModal.svelte b/src/lib/components/JoinModal.svelte index 4fe7757..babecaa 100644 --- a/src/lib/components/JoinModal.svelte +++ b/src/lib/components/JoinModal.svelte @@ -1,19 +1,38 @@