Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix Space profile loading and message races

Anand Baburajan465b52bcb950
diff --git a/web/apps/space/src/components/SpaceRouteFallback.tsx b/web/apps/space/src/components/SpaceRouteFallback.tsx
index 69d4585910..27b0d6f6cd 100644
--- a/web/apps/space/src/components/SpaceRouteFallback.tsx
+++ b/web/apps/space/src/components/SpaceRouteFallback.tsx
@@ -3,7 +3,10 @@ import { SpacePageMeta } from "components/SpacePageMeta";
import React from "react";
interface SpaceRouteFallbackProps {
+ actionLabel?: string;
background: string;
+ message?: string;
+ onAction?: () => void;
}
interface SpaceLoadingSpinnerProps {
@@ -32,19 +35,66 @@ export const SpaceLoadingSpinner: React.FC<SpaceLoadingSpinnerProps> = ({
);
export const SpaceRouteFallback: React.FC<SpaceRouteFallbackProps> = ({
+ actionLabel,
background,
+ message,
+ onAction,
}) => (
<>
<SpacePageMeta themeColor={background} />
<Box
sx={{
+ alignItems: "center",
bgcolor: background,
display: "grid",
minHeight: "100svh",
placeItems: "center",
+ px: 3,
+ textAlign: "center",
}}
>
- <SpaceLoadingSpinner />
+ {message ? (
+ <Box sx={{ maxWidth: 300 }}>
+ <Box
+ role="alert"
+ sx={{
+ color: "#111111",
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 14,
+ fontWeight: 600,
+ lineHeight: "20px",
+ }}
+ >
+ {message}
+ </Box>
+ {actionLabel && onAction && (
+ <Box
+ component="button"
+ type="button"
+ onClick={onAction}
+ sx={{
+ bgcolor: "#08C225",
+ border: 0,
+ borderRadius: "18px",
+ color: "white",
+ cursor: "pointer",
+ fontFamily:
+ '"Inter Variable", Inter, sans-serif',
+ fontSize: 13,
+ fontWeight: 700,
+ height: 36,
+ lineHeight: "18px",
+ mt: 2,
+ px: "16px",
+ }}
+ >
+ {actionLabel}
+ </Box>
+ )}
+ </Box>
+ ) : (
+ <SpaceLoadingSpinner />
+ )}
</Box>
</>
);
diff --git a/web/apps/space/src/pages/app/friends/[spaceId].tsx b/web/apps/space/src/pages/app/friends/[spaceId].tsx
index 0b047616e2..2f720ed0f6 100644
--- a/web/apps/space/src/pages/app/friends/[spaceId].tsx
+++ b/web/apps/space/src/pages/app/friends/[spaceId].tsx
@@ -29,8 +29,14 @@ const friendSpaceIdFromPath = () => {
const Page: React.FC = () => {
const router = useRouter();
- const { friends, profile, profileLoadStatus, setFriends } =
- useSpaceAppState();
+ const {
+ friends,
+ profile,
+ profileLoadError,
+ profileLoadStatus,
+ refreshProfile,
+ setFriends,
+ } = useSpaceAppState();
const friendSpaceId =
friendSpaceIdFromQuery(router.query.spaceId) || friendSpaceIdFromPath();
const selectedFriend = friends.find(
@@ -96,11 +102,18 @@ const Page: React.FC = () => {
if (
!router.isReady ||
- profileLoadStatus == "loading" ||
+ profileLoadStatus != "ready" ||
!profile ||
!selectedFriend
) {
- return <SpaceRouteFallback background={friendsBackground} />;
+ return (
+ <SpaceRouteFallback
+ actionLabel={profileLoadStatus == "error" ? "Retry" : undefined}
+ background={friendsBackground}
+ message={profileLoadError}
+ onAction={() => void refreshProfile()}
+ />
+ );
}
return (
diff --git a/web/apps/space/src/pages/app/friends/index.tsx b/web/apps/space/src/pages/app/friends/index.tsx
index 28e1ddf55b..0c388f141e 100644
--- a/web/apps/space/src/pages/app/friends/index.tsx
+++ b/web/apps/space/src/pages/app/friends/index.tsx
@@ -12,8 +12,14 @@ import { spaceRoutes } from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
- const { friends, profile, profileLoadStatus, setFriends } =
- useSpaceAppState();
+ const {
+ friends,
+ profile,
+ profileLoadError,
+ profileLoadStatus,
+ refreshProfile,
+ setFriends,
+ } = useSpaceAppState();
useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
@@ -31,8 +37,15 @@ const Page: React.FC = () => {
);
}, [profile?.spaceId, setFriends]);
- if (profileLoadStatus == "loading" || !profile) {
- return <SpaceRouteFallback background={friendsBackground} />;
+ if (profileLoadStatus != "ready" || !profile) {
+ return (
+ <SpaceRouteFallback
+ actionLabel={profileLoadStatus == "error" ? "Retry" : undefined}
+ background={friendsBackground}
+ message={profileLoadError}
+ onAction={() => void refreshProfile()}
+ />
+ );
}
return (
diff --git a/web/apps/space/src/pages/app/index.tsx b/web/apps/space/src/pages/app/index.tsx
index 0f03572332..7d78d7b265 100644
--- a/web/apps/space/src/pages/app/index.tsx
+++ b/web/apps/space/src/pages/app/index.tsx
@@ -21,12 +21,16 @@ import { firstNameFrom } from "utils/spaceDisplay";
import { spacePostToViewerPhoto } from "utils/spacePostDisplay";
import { spaceRoutes } from "utils/spaceRoutes";
-const loadingHomeProfile = { avatarUrl: null, fullName: "", username: "" };
-
const Page: React.FC = () => {
const router = useRouter();
- const { friends, profile, profileLoadStatus, setFriends } =
- useSpaceAppState();
+ const {
+ friends,
+ profile,
+ profileLoadError,
+ profileLoadStatus,
+ refreshProfile,
+ setFriends,
+ } = useSpaceAppState();
const [addedFriendToastName, setAddedFriendToastName] = useState<string>();
const [feedItems, setFeedItems] = useState<SpacePost[]>([]);
const [hasUnreadNotifications, setHasUnreadNotifications] = useState(false);
@@ -54,7 +58,7 @@ const Page: React.FC = () => {
}, [router.isReady]);
useEffect(() => {
- if (profileLoadStatus == "loading") return;
+ if (profileLoadStatus != "ready") return;
const spaceId = profile?.spaceId;
if (!spaceId) {
@@ -95,12 +99,17 @@ const Page: React.FC = () => {
};
}, [profile?.spaceId, profileLoadStatus, setFriends]);
- if (profileLoadStatus == "ready" && !profile) {
- return <SpaceRouteFallback background={homeBackground} />;
+ if (profileLoadStatus != "ready" || !profile) {
+ return (
+ <SpaceRouteFallback
+ actionLabel={profileLoadStatus == "error" ? "Retry" : undefined}
+ background={homeBackground}
+ message={profileLoadError}
+ onAction={() => void refreshProfile()}
+ />
+ );
}
- const screenProfile = profile ?? loadingHomeProfile;
-
return (
<>
<SpacePageMeta themeColor={homeBackground} />
@@ -110,10 +119,10 @@ const Page: React.FC = () => {
addedFriendToastName={addedFriendToastName}
hasUnreadNotifications={hasUnreadNotifications}
isFeedLoading={isFeedLoading}
- profile={screenProfile}
+ profile={profile}
onAddedFriendToastClose={closeAddedFriendToast}
onCreatePost={async (image, caption) => {
- if (!profile?.spaceId) throw new Error("Missing space.");
+ if (!profile.spaceId) throw new Error("Missing space.");
const post = await createCurrentPhotoPost({
caption,
file: image.file,
@@ -135,7 +144,7 @@ const Page: React.FC = () => {
onReplyToPost={replyToCurrentPost}
onSetPostLiked={setCurrentPostLiked}
onShareProfileLink={async () => {
- if (!profile?.spaceId) throw new Error("Missing space.");
+ if (!profile.spaceId) throw new Error("Missing space.");
return (await createCurrentProfileLink(profile.spaceId))
.url;
}}
diff --git a/web/apps/space/src/pages/app/notifications.tsx b/web/apps/space/src/pages/app/notifications.tsx
index b35cee559a..9c472a9286 100644
--- a/web/apps/space/src/pages/app/notifications.tsx
+++ b/web/apps/space/src/pages/app/notifications.tsx
@@ -20,8 +20,14 @@ import { spaceRoutes } from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
- const { friends, profile, profileLoadStatus, setFriends } =
- useSpaceAppState();
+ const {
+ friends,
+ profile,
+ profileLoadError,
+ profileLoadStatus,
+ refreshProfile,
+ setFriends,
+ } = useSpaceAppState();
const [conversations, setConversations] = React.useState<
SpaceMessageConversation[]
>([]);
@@ -34,6 +40,9 @@ const Page: React.FC = () => {
SpaceMessageConversation["friend"] | undefined
>();
const selectedFriendSpaceId = selectedFriend?.spaceId ?? selectedFriend?.id;
+ const selectedFriendSpaceIdRef = React.useRef<string | undefined>(
+ undefined,
+ );
const selectedFriendSpaceSlug = selectedFriend?.spaceSlug;
const selectedFriendUsername = selectedFriend?.username;
const isSelectedFriendCurrent = Boolean(
@@ -70,6 +79,7 @@ const Page: React.FC = () => {
setSelectedFriend(conversation.friend);
const friendSpaceId =
conversation.friend.spaceId ?? conversation.friend.id;
+ selectedFriendSpaceIdRef.current = friendSpaceId;
setConversations((currentConversations) =>
currentConversations.map((currentConversation) =>
(currentConversation.friend.spaceId ??
@@ -91,10 +101,19 @@ const Page: React.FC = () => {
const closeConversation = React.useCallback(() => {
setSelectedFriend(undefined);
+ selectedFriendSpaceIdRef.current = undefined;
setIsThreadLoading(false);
setMessages([]);
}, []);
+ const appendMessageIfThreadIsCurrent = React.useCallback(
+ (spaceId: string, message: SpaceMessage) => {
+ if (selectedFriendSpaceIdRef.current != spaceId) return;
+ setMessages((currentMessages) => [...currentMessages, message]);
+ },
+ [],
+ );
+
React.useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
void router.replace(spaceRoutes.onboarding);
@@ -122,16 +141,17 @@ const Page: React.FC = () => {
React.useEffect(() => {
if (!selectedFriend) {
+ selectedFriendSpaceIdRef.current = undefined;
setMessages([]);
setIsThreadLoading(false);
return;
}
let cancelled = false;
+ const threadSpaceId = selectedFriend.spaceId ?? selectedFriend.id;
+ selectedFriendSpaceIdRef.current = threadSpaceId;
setIsThreadLoading(true);
- void loadCurrentMessageThread(
- selectedFriend.spaceId ?? selectedFriend.id,
- )
+ void loadCurrentMessageThread(threadSpaceId)
.then((page) => {
if (!cancelled) setMessages(page.items);
})
@@ -147,8 +167,15 @@ const Page: React.FC = () => {
};
}, [selectedFriend]);
- if (profileLoadStatus == "loading" || !profile) {
- return <SpaceRouteFallback background={messagesBackground} />;
+ if (profileLoadStatus != "ready" || !profile) {
+ return (
+ <SpaceRouteFallback
+ actionLabel={profileLoadStatus == "error" ? "Retry" : undefined}
+ background={messagesBackground}
+ message={profileLoadError}
+ onAction={() => void refreshProfile()}
+ />
+ );
}
return (
@@ -172,10 +199,7 @@ const Page: React.FC = () => {
onOpenThread={openConversation}
onSendMessage={async (spaceId, text) => {
const message = await sendCurrentMessage(spaceId, text);
- setMessages((currentMessages) => [
- ...currentMessages,
- message,
- ]);
+ appendMessageIfThreadIsCurrent(spaceId, message);
refreshConversations();
}}
onReplyToMessage={async (spaceId, messageId, text) => {
@@ -184,10 +208,7 @@ const Page: React.FC = () => {
messageId,
text,
);
- setMessages((currentMessages) => [
- ...currentMessages,
- message,
- ]);
+ appendMessageIfThreadIsCurrent(spaceId, message);
refreshConversations();
}}
onSetMessageLiked={async (messageId, liked) => {
diff --git a/web/apps/space/src/pages/app/profile.tsx b/web/apps/space/src/pages/app/profile.tsx
index 6b089068b8..8df64aea5c 100644
--- a/web/apps/space/src/pages/app/profile.tsx
+++ b/web/apps/space/src/pages/app/profile.tsx
@@ -22,8 +22,14 @@ import { spaceRoutes } from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
- const { friends, profile, profileLoadStatus, setFriends } =
- useSpaceAppState();
+ const {
+ friends,
+ profile,
+ profileLoadError,
+ profileLoadStatus,
+ refreshProfile,
+ setFriends,
+ } = useSpaceAppState();
const [posts, setPosts] = useState<SpacePost[]>([]);
const [isPostsLoading, setIsPostsLoading] = useState(true);
const postGroups = useMemo(
@@ -38,7 +44,7 @@ const Page: React.FC = () => {
}, [profile, profileLoadStatus, router]);
useEffect(() => {
- if (profileLoadStatus == "loading") return;
+ if (profileLoadStatus != "ready") return;
const spaceId = profile?.spaceId;
if (!spaceId) {
@@ -69,8 +75,15 @@ const Page: React.FC = () => {
};
}, [profile?.spaceId, profileLoadStatus, setFriends]);
- if (profileLoadStatus == "loading" || !profile) {
- return <SpaceRouteFallback background={profileBackground} />;
+ if (profileLoadStatus != "ready" || !profile) {
+ return (
+ <SpaceRouteFallback
+ actionLabel={profileLoadStatus == "error" ? "Retry" : undefined}
+ background={profileBackground}
+ message={profileLoadError}
+ onAction={() => void refreshProfile()}
+ />
+ );
}
return (
diff --git a/web/apps/space/src/pages/app/settings.tsx b/web/apps/space/src/pages/app/settings.tsx
index 58b56f72d9..c3926b0acc 100644
--- a/web/apps/space/src/pages/app/settings.tsx
+++ b/web/apps/space/src/pages/app/settings.tsx
@@ -9,7 +9,13 @@ import { spaceRoutes } from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
- const { profile, profileLoadStatus, resetAfterLogout } = useSpaceAppState();
+ const {
+ profile,
+ profileLoadError,
+ profileLoadStatus,
+ refreshProfile,
+ resetAfterLogout,
+ } = useSpaceAppState();
useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
@@ -17,8 +23,15 @@ const Page: React.FC = () => {
}
}, [profile, profileLoadStatus, router]);
- if (profileLoadStatus == "loading" || !profile) {
- return <SpaceRouteFallback background={settingsBackground} />;
+ if (profileLoadStatus != "ready" || !profile) {
+ return (
+ <SpaceRouteFallback
+ actionLabel={profileLoadStatus == "error" ? "Retry" : undefined}
+ background={settingsBackground}
+ message={profileLoadError}
+ onAction={() => void refreshProfile()}
+ />
+ );
}
return (
diff --git a/web/apps/space/src/pages/index.tsx b/web/apps/space/src/pages/index.tsx
index 746275813b..60ca7c2a74 100644
--- a/web/apps/space/src/pages/index.tsx
+++ b/web/apps/space/src/pages/index.tsx
@@ -96,7 +96,9 @@ const Page: React.FC = () => {
const {
onboardingEntrySource,
profile,
+ profileLoadError,
profileLoadStatus,
+ refreshProfile,
setOnboardingEntrySource,
} = useSpaceAppState();
const [routeMode, setRouteMode] = useState<RouteMode>({ kind: "checking" });
@@ -198,6 +200,19 @@ const Page: React.FC = () => {
const shouldCheckUnlock =
routeMode.kind == "app" && profileLoadStatus == "ready" && !profile;
+ const hasProfileLoadError =
+ routeMode.kind == "app" && profileLoadStatus == "error";
+
+ if (hasProfileLoadError) {
+ return (
+ <SpaceRouteFallback
+ actionLabel="Retry"
+ background={profileBackground}
+ message={profileLoadError}
+ onAction={() => void refreshProfile()}
+ />
+ );
+ }
if (
routeMode.kind == "checking" ||
diff --git a/web/apps/space/src/pages/invite.tsx b/web/apps/space/src/pages/invite.tsx
index 27f3e52a63..3f4c3f0f57 100644
--- a/web/apps/space/src/pages/invite.tsx
+++ b/web/apps/space/src/pages/invite.tsx
@@ -12,7 +12,8 @@ import { spaceRoutes } from "utils/spaceRoutes";
const Page: React.FC = () => {
const router = useRouter();
- const { profile, profileLoadStatus } = useSpaceAppState();
+ const { profile, profileLoadError, profileLoadStatus, refreshProfile } =
+ useSpaceAppState();
const [profileLink, setProfileLink] = useState<string>();
const [linkError, setLinkError] = useState<string>();
const [isLinkLoading, setIsLinkLoading] = useState(false);
@@ -44,8 +45,15 @@ const Page: React.FC = () => {
if (!profileLink) void loadInviteLink();
}, [loadInviteLink, profileLink]);
- if (profileLoadStatus == "loading" || !profile) {
- return <SpaceRouteFallback background={shareProfileLinkBackground} />;
+ if (profileLoadStatus != "ready" || !profile) {
+ return (
+ <SpaceRouteFallback
+ actionLabel={profileLoadStatus == "error" ? "Retry" : undefined}
+ background={shareProfileLinkBackground}
+ message={profileLoadError}
+ onAction={() => void refreshProfile()}
+ />
+ );
}
return (
@@ -55,9 +63,7 @@ const Page: React.FC = () => {
errorMessage={linkError}
isLinkLoading={isLinkLoading}
profile={profile}
- onBack={() =>
- void router.push(spaceRoutes.setupProfile())
- }
+ onBack={() => void router.push(spaceRoutes.setupProfile())}
onDone={() => void router.push(spaceRoutes.home)}
onRetry={() => void loadInviteLink()}
profileLink={profileLink}
diff --git a/web/apps/space/src/pages/setup-profile.tsx b/web/apps/space/src/pages/setup-profile.tsx
index c02bf166c1..ddf461a10a 100644
--- a/web/apps/space/src/pages/setup-profile.tsx
+++ b/web/apps/space/src/pages/setup-profile.tsx
@@ -28,6 +28,7 @@ const Page: React.FC = () => {
const {
onboardingEntrySource,
profile,
+ profileLoadError,
profileLoadStatus,
refreshProfile,
setProfile,
@@ -123,8 +124,15 @@ const Page: React.FC = () => {
};
}, [draftUsername, profile, profileLoadStatus]);
- if (profileLoadStatus == "loading" || profile) {
- return <SpaceRouteFallback background={setupProfileBackground} />;
+ if (profileLoadStatus != "ready" || profile) {
+ return (
+ <SpaceRouteFallback
+ actionLabel={profileLoadStatus == "error" ? "Retry" : undefined}
+ background={setupProfileBackground}
+ message={profileLoadError}
+ onAction={() => void refreshProfile()}
+ />
+ );
}
return (
diff --git a/web/apps/space/src/services/space.ts b/web/apps/space/src/services/space.ts
index 94a58a72fb..4a5eeb3d3c 100644
--- a/web/apps/space/src/services/space.ts
+++ b/web/apps/space/src/services/space.ts
@@ -313,9 +313,7 @@ const cachedBlobURL = (
spaceMediaURLCache.set(key, promise);
while (spaceMediaURLCache.size > maxSpaceMediaCacheEntries) {
- const oldest = spaceMediaURLCache.entries().next().value as
- | [string, Promise<string>]
- | undefined;
+ const oldest = spaceMediaURLCache.entries().next().value;
if (!oldest) break;
spaceMediaURLCache.delete(oldest[0]);
void oldest[1].then(
@@ -523,7 +521,11 @@ const postFromLinkPost = async (
if (!object) return null;
const author = actorProfile(post.author);
- author.avatarUrl = await linkAvatarURL(ctx, post.author.avatar, avatarCache);
+ author.avatarUrl = await linkAvatarURL(
+ ctx,
+ post.author.avatar,
+ avatarCache,
+ );
const imageUrl = blobURLForBytes(
await ctx.download_post_asset_with_key(
diff --git a/web/apps/space/src/services/spaceProfile.ts b/web/apps/space/src/services/spaceProfile.ts
index 53097a0796..7ee6dc2b3a 100644
--- a/web/apps/space/src/services/spaceProfile.ts
+++ b/web/apps/space/src/services/spaceProfile.ts
@@ -122,12 +122,9 @@ const currentSpaceContextConfig = async () => {
}
return {
- cacheKey: [
- user.id,
- authToken,
- baseUrl,
- keyAttributes.publicKey,
- ].join(":"),
+ cacheKey: [user.id, authToken, baseUrl, keyAttributes.publicKey].join(
+ ":",
+ ),
input: {
authToken,
baseUrl,
@@ -208,6 +205,7 @@ export const ensureCurrentSpaceContext = async () => {
};
export const releaseCurrentSpaceContext = (_ctx: SpaceAccountCtxHandle) => {
+ void _ctx;
// Shared context is freed by clearCurrentSpaceContext on logout/session change.
};
diff --git a/web/apps/space/src/state/SpaceAppStateProvider.tsx b/web/apps/space/src/state/SpaceAppStateProvider.tsx
index 7de44f0cc5..0b51840c55 100644
--- a/web/apps/space/src/state/SpaceAppStateProvider.tsx
+++ b/web/apps/space/src/state/SpaceAppStateProvider.tsx
@@ -7,11 +7,11 @@ import React, {
} from "react";
import type { SpaceLoginCredentials } from "screens/LoginScreen";
import type { SetupProfile } from "screens/SetupProfileScreen";
-import type { PendingSpacePasskeyVerification } from "services/spacePasskeyVerification";
import {
clearSpaceFriendsCache,
clearSpaceMediaURLCache,
} from "services/space";
+import type { PendingSpacePasskeyVerification } from "services/spacePasskeyVerification";
import {
clearCurrentSpaceContext,
loadExistingSpaceAvatar,
@@ -38,6 +38,7 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({
const [pendingPasskeyVerification, setPendingPasskeyVerification] =
useState<PendingSpacePasskeyVerification | null>(null);
const [profile, setProfile] = useState<SetupProfile | null>(null);
+ const [profileLoadError, setProfileLoadError] = useState<string>();
const [profileLoadStatus, setProfileLoadStatus] =
useState<SpaceProfileLoadStatus>("loading");
const [signupEmail, setSignupEmail] = useState("");
@@ -93,27 +94,32 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({
[applyProfile],
);
+ const profileErrorMessage = (error: unknown) =>
+ error instanceof Error
+ ? error.message
+ : "Couldn't load your Space profile. Please try again.";
+
const refreshProfile = useCallback(async () => {
const generation = ++profileLoadGenerationRef.current;
+ setProfileLoadError(undefined);
setProfileLoadStatus("loading");
try {
const nextProfile = await loadExistingSpaceProfile();
if (profileLoadGenerationRef.current == generation) {
+ setProfileLoadError(undefined);
applyProfile(nextProfile);
void loadProfileAvatar(nextProfile, generation);
+ setProfileLoadStatus("ready");
}
return nextProfile;
} catch (error) {
console.error("Failed to load space profile", error);
if (profileLoadGenerationRef.current == generation) {
- applyProfile(null);
+ setProfileLoadError(profileErrorMessage(error));
+ setProfileLoadStatus("error");
}
return null;
- } finally {
- if (profileLoadGenerationRef.current == generation) {
- setProfileLoadStatus("ready");
- }
}
}, [applyProfile, loadProfileAvatar]);
@@ -123,6 +129,7 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({
clearSpaceFriendsCache();
clearSpaceMediaURLCache();
applyProfile(null);
+ setProfileLoadError(undefined);
setProfileLoadStatus("ready");
setPendingLoginCredentials(null);
setPendingPasskeyVerification(null);
@@ -142,6 +149,7 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({
pendingLoginCredentials,
pendingPasskeyVerification,
profile,
+ profileLoadError,
profileLoadStatus,
refreshProfile,
resetAfterLogout,
@@ -161,6 +169,7 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({
pendingLoginCredentials,
pendingPasskeyVerification,
profile,
+ profileLoadError,
profileLoadStatus,
refreshProfile,
resetAfterLogout,
diff --git a/web/apps/space/src/state/spaceAppState.tsx b/web/apps/space/src/state/spaceAppState.tsx
index 4a3d0348f5..a2312b54d2 100644
--- a/web/apps/space/src/state/spaceAppState.tsx
+++ b/web/apps/space/src/state/spaceAppState.tsx
@@ -5,7 +5,7 @@ import type { SetupProfile } from "screens/SetupProfileScreen";
import type { PendingSpacePasskeyVerification } from "services/spacePasskeyVerification";
export type OnboardingEntrySource = "direct" | "add-friend-link";
-export type SpaceProfileLoadStatus = "loading" | "ready";
+export type SpaceProfileLoadStatus = "error" | "loading" | "ready";
export interface SpaceAppState {
friends: FriendProfile[];
@@ -14,6 +14,7 @@ export interface SpaceAppState {
pendingLoginCredentials: SpaceLoginCredentials | null;
pendingPasskeyVerification: PendingSpacePasskeyVerification | null;
profile: SetupProfile | null;
+ profileLoadError?: string;
profileLoadStatus: SpaceProfileLoadStatus;
signupEmail: string;
refreshProfile: () => Promise<SetupProfile | null>;