@@ -27,6 +27,8 @@ import { useCommunityInit } from "@/features/communities/useCommunityInit";
2727import { useNestNotifications } from "@/features/communities/useNestNotifications" ;
2828import { useCommunities } from "@/features/communities/useCommunities" ;
2929import { WelcomeSetup } from "@/features/communities/ui/WelcomeSetup" ;
30+ import { CommunityApplyErrorScreen } from "@/features/communities/ui/CommunityApplyErrorScreen" ;
31+ import { CommunityChangeOverlay } from "@/features/communities/ui/CommunityChangeOverlay" ;
3032import { createBuzzQueryClient } from "@/shared/api/queryClient" ;
3133import { isSharedIdentity as isSharedIdentityCmd } from "@/shared/api/tauri" ;
3234import { listenForDeepLinks } from "@/shared/deep-link" ;
@@ -274,19 +276,15 @@ function CommunityQueryProvider({ children }: { children: ReactNode }) {
274276}
275277
276278function AppReady ( {
277- canBackToCommunitySetup,
278279 isCompletingFirstRunCommunity,
279280 isSharedIdentity,
280281 isCommunitySwitch,
281282 onFirstRunCommunitySettled,
282- onBackToCommunitySetup,
283283} : {
284- canBackToCommunitySetup : boolean ;
285284 isCompletingFirstRunCommunity : boolean ;
286285 isSharedIdentity : boolean ;
287286 isCommunitySwitch : boolean ;
288287 onFirstRunCommunitySettled : ( ) => void ;
289- onBackToCommunitySetup : ( ) => void ;
290288} ) {
291289 const onboarding = useAppOnboardingState ( isSharedIdentity ) ;
292290
@@ -316,11 +314,9 @@ function AppReady({
316314 return (
317315 < OnboardingFlow
318316 actions = { onboarding . flow . actions }
319- canBackToCommunitySetup = { canBackToCommunitySetup }
320317 identityLost = { onboarding . identityLost }
321318 initialProfile = { onboarding . flow . initialProfile }
322319 key = { onboarding . currentPubkey ?? "anonymous" }
323- onBackToCommunitySetup = { onBackToCommunitySetup }
324320 />
325321 ) ;
326322 }
@@ -360,16 +356,12 @@ export function App() {
360356 activeCommunity,
361357 reinitKey,
362358 addCommunity,
363- clearCommunities,
364359 switchCommunity,
365360 reconnectCommunity,
366361 } = useCommunities ( ) ;
367362 const [ isCompletingFirstRunCommunity , setIsCompletingFirstRunCommunity ] =
368363 useState ( false ) ;
369- const [ canBackToCommunitySetup , setCanBackToCommunitySetup ] = useState ( false ) ;
370- const [ welcomeTransitionMode , setWelcomeTransitionMode ] = useState <
371- "initial" | "backward"
372- > ( "initial" ) ;
364+ const [ isCommunityChangeOpen , setIsCommunityChangeOpen ] = useState ( false ) ;
373365
374366 useEffect ( ( ) => {
375367 const unlisten = listenForDeepLinks ( {
@@ -408,22 +400,13 @@ export function App() {
408400
409401 const handleSetupComplete = useCallback (
410402 ( community : Community ) => {
411- setWelcomeTransitionMode ( "initial" ) ;
412403 setIsCompletingFirstRunCommunity ( true ) ;
413- setCanBackToCommunitySetup ( true ) ;
414404 const communityId = addCommunity ( community ) ;
415405 switchCommunity ( communityId ) ;
416406 } ,
417407 [ addCommunity , switchCommunity ] ,
418408 ) ;
419409
420- const handleBackToCommunitySetup = useCallback ( ( ) => {
421- setWelcomeTransitionMode ( "backward" ) ;
422- setIsCompletingFirstRunCommunity ( false ) ;
423- setCanBackToCommunitySetup ( false ) ;
424- clearCommunities ( ) ;
425- } , [ clearCommunities ] ) ;
426-
427410 const handleFirstRunCommunitySettled = useCallback ( ( ) => {
428411 setIsCompletingFirstRunCommunity ( false ) ;
429412 } , [ ] ) ;
@@ -442,12 +425,29 @@ export function App() {
442425 return (
443426 < WelcomeSetup
444427 defaultRelayUrl = { community . defaultRelayUrl }
445- initialTransitionMode = { welcomeTransitionMode }
446428 onComplete = { handleSetupComplete }
447429 />
448430 ) ;
449431 }
450432
433+ // Surface apply failures so the user can retry or change community.
434+ if ( "error" in community && community . error ) {
435+ return (
436+ < >
437+ < CommunityApplyErrorScreen
438+ error = { community . error }
439+ onChangeCommunity = { ( ) => setIsCommunityChangeOpen ( true ) }
440+ onRetry = { reconnectCommunity }
441+ />
442+ { isCommunityChangeOpen ? (
443+ < CommunityChangeOverlay
444+ onClose = { ( ) => setIsCommunityChangeOpen ( false ) }
445+ />
446+ ) : null }
447+ </ >
448+ ) ;
449+ }
450+
451451 // Wait for this exact community config to be applied to the backend before
452452 // rendering anything that connects to the relay. The appliedKey check avoids
453453 // a one-render race where React sees the new active community while the Tauri
@@ -471,13 +471,11 @@ export function App() {
471471 return (
472472 < CommunityQueryProvider key = { communityKey } >
473473 < AppReady
474- canBackToCommunitySetup = { canBackToCommunitySetup }
475474 isCompletingFirstRunCommunity = { isCompletingFirstRunCommunity }
476475 isCommunitySwitch = { isCommunitySwitch }
477476 key = { communityKey }
478477 isSharedIdentity = { sharedIdentity }
479478 onFirstRunCommunitySettled = { handleFirstRunCommunitySettled }
480- onBackToCommunitySetup = { handleBackToCommunitySetup }
481479 />
482480 { showBootSplashOverlay ? (
483481 < div
0 commit comments