mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix(desktop): route first community deep links into onboarding (#2055)
Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
+18
-3
@@ -40,7 +40,10 @@ import { CommunityApplyErrorScreen } from "@/features/communities/ui/CommunityAp
|
||||
import { CommunityChangeOverlay } from "@/features/communities/ui/CommunityChangeOverlay";
|
||||
import { createBuzzQueryClient } from "@/shared/api/queryClient";
|
||||
import { isSharedIdentity as isSharedIdentityCmd } from "@/shared/api/tauri";
|
||||
import { listenForDeepLinks } from "@/shared/deep-link";
|
||||
import {
|
||||
type AddCommunityDeepLinkPayload,
|
||||
listenForDeepLinks,
|
||||
} from "@/shared/deep-link";
|
||||
import { cn } from "@/shared/lib/cn";
|
||||
import { BuzzMark } from "@/shared/ui/buzz-logo/BuzzMark";
|
||||
import { FlappingBee } from "@/shared/ui/buzz-logo/FlappingBee";
|
||||
@@ -421,6 +424,18 @@ function MachineBootstrap({ sharedIdentity }: { sharedIdentity: boolean }) {
|
||||
[machine.complete],
|
||||
);
|
||||
|
||||
const openAddCommunity = useCallback(
|
||||
(payload: AddCommunityDeepLinkPayload & { requestId: string }) =>
|
||||
activeCommunity
|
||||
? requestAddCommunityPrefill(payload)
|
||||
: communityOnboarding.start({
|
||||
source: "add-community",
|
||||
relayUrl: payload.relayUrl,
|
||||
communityName: payload.name,
|
||||
}),
|
||||
[activeCommunity, communityOnboarding.start],
|
||||
);
|
||||
|
||||
// Deep links are captured here — above the machine-onboarding gate — not in
|
||||
// CommunityApp. The Rust side queues them; draining into the persisted
|
||||
// community-onboarding transaction immediately means an invite opened on a
|
||||
@@ -429,13 +444,13 @@ function MachineBootstrap({ sharedIdentity }: { sharedIdentity: boolean }) {
|
||||
useEffect(() => {
|
||||
const unlisten = listenForDeepLinks({
|
||||
startCommunityOnboarding: communityOnboarding.start,
|
||||
openAddCommunity: requestAddCommunityPrefill,
|
||||
openAddCommunity,
|
||||
onAddCommunityAvailable: onAddCommunityPrefillAvailable,
|
||||
});
|
||||
return () => {
|
||||
void unlisten.then((fn) => fn());
|
||||
};
|
||||
}, [communityOnboarding.start]);
|
||||
}, [communityOnboarding.start, openAddCommunity]);
|
||||
|
||||
if (machine.stage === "reset-failed") return <ResetFailedScreen />;
|
||||
if (machine.stage === "keyring-locked") return <KeyringLockedScreen />;
|
||||
|
||||
@@ -110,6 +110,38 @@ test("connect deep link shows a static acknowledgment during setup", async ({
|
||||
.toContain('"acknowledged":true');
|
||||
});
|
||||
|
||||
test("add-community deep link starts onboarding when no community is configured", async ({
|
||||
page,
|
||||
}) => {
|
||||
await installMockBridge(
|
||||
page,
|
||||
{ pendingCommunityDeepLinks: [PENDING_ADD_COMMUNITY_LINK] },
|
||||
{ skipCommunitySeed: true },
|
||||
);
|
||||
await page.goto("/");
|
||||
|
||||
await expect(page.getByTestId("community-onboarding-flow")).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Build your profile" }),
|
||||
).toBeVisible();
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(
|
||||
(key) => window.localStorage.getItem(key),
|
||||
TRANSACTION_STORAGE_KEY,
|
||||
),
|
||||
)
|
||||
.toContain('"source":"add-community"');
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(
|
||||
(key) => window.localStorage.getItem(key),
|
||||
TRANSACTION_STORAGE_KEY,
|
||||
),
|
||||
)
|
||||
.toContain('"communityName":"Acme Team"');
|
||||
});
|
||||
|
||||
test("add-community deep link opens one editable prefill and acknowledges the queue", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in New Issue
Block a user