diff --git a/desktop/src/features/communities/ui/WelcomeSetup.tsx b/desktop/src/features/communities/ui/WelcomeSetup.tsx index 964e105f8f..bde1458222 100644 --- a/desktop/src/features/communities/ui/WelcomeSetup.tsx +++ b/desktop/src/features/communities/ui/WelcomeSetup.tsx @@ -1,4 +1,5 @@ import * as React from "react"; +import { Check, Copy } from "lucide-react"; import { HostedCommunityOnboarding } from "@/features/communities/ui/HostedCommunityOnboarding"; import { useCommunityOnboarding } from "@/features/onboarding/communityOnboarding"; @@ -12,6 +13,9 @@ import { type OnboardingTransitionDirection, OnboardingSlideTransition, } from "@/features/onboarding/ui/OnboardingSlideTransition"; +import { useIdentityQuery } from "@/shared/api/hooks"; +import { writeTextToClipboard } from "@/shared/lib/clipboard"; +import { pubkeyToNpub } from "@/shared/lib/nostrUtils"; import { useSystemColorScheme } from "@/shared/theme/useSystemColorScheme"; import { Button } from "@/shared/ui/button"; import { Card } from "@/shared/ui/card"; @@ -41,8 +45,18 @@ export function WelcomeSetup({ // we only navigate to the hosted stage once sign-in completes, so the page // behind the modal never changes out from under the user. const [isHostedSignInOpen, setIsHostedSignInOpen] = React.useState(false); + const [copiedNpub, setCopiedNpub] = React.useState(false); const communityOnboarding = useCommunityOnboarding(); + const identityQuery = useIdentityQuery(); const systemColorScheme = useSystemColorScheme(); + const npub = identityQuery.data?.pubkey + ? pubkeyToNpub(identityQuery.data.pubkey) + : ""; + const npubError = identityQuery.error + ? identityQuery.error instanceof Error + ? identityQuery.error.message + : "Could not load your public key." + : null; const showPage = React.useCallback( (nextPage: WelcomeSetupPage, direction?: OnboardingTransitionDirection) => { @@ -243,7 +257,7 @@ export function WelcomeSetup({ : "Enter the invite link or community URL you received."}

-
+
+ {page === "join" ? ( +
+

+ Joining a private community? +

+

+ Some communities need the owner to add you before you can + join. Copy your public ID and send it to the community + owner. +

+
+ + {npub || "Loading…"} + + +
+ {npubError ? ( +

+ {npubError} +

+ ) : null} +
+ ) : null}
)} diff --git a/desktop/tests/e2e/onboarding.spec.ts b/desktop/tests/e2e/onboarding.spec.ts index 86e22189e4..bb916d8011 100644 --- a/desktop/tests/e2e/onboarding.spec.ts +++ b/desktop/tests/e2e/onboarding.spec.ts @@ -621,6 +621,11 @@ test("first-community choices route join, create, owner, and member intents", as await expect( page.getByRole("heading", { name: "Join a community" }), ).toBeVisible(); + await expect(page.getByText("Joining a private community?")).toBeVisible(); + await expect(page.getByTestId("welcome-join-npub")).toBeVisible(); + await expect( + page.getByRole("button", { name: "Copy public ID" }), + ).toBeVisible(); await accessInput.fill("https://default.example.com/invite/abc123"); await expect(page.getByTestId("invite-redeem-submit")).toBeEnabled(); });