π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Wire Space web profile assets to object IDs
Neeraj Gupta65da796ff268
diff --git a/web/apps/space/src/components/SpaceMessagesPage.tsx b/web/apps/space/src/components/SpaceMessagesPage.tsxindex 6a23da4c07..692758b51b 100644--- a/web/apps/space/src/components/SpaceMessagesPage.tsx+++ b/web/apps/space/src/components/SpaceMessagesPage.tsx@@ -63,7 +63,7 @@ const placeholderFriend = (const currentProfileMessageActor = (profile: SetupProfile,): SpaceMessage["sender"] => ({- avatarObjectKey: profile.avatarObjectKey,+ avatarObjectID: profile.avatarObjectID,avatarUpdatedAt: profile.avatarUpdatedAt,avatarUrl: profile.avatarUrl,friendsCount: 0,diff --git a/web/apps/space/src/data/friends.ts b/web/apps/space/src/data/friends.tsindex 6dbe601b2c..c6c879b15d 100644--- a/web/apps/space/src/data/friends.ts+++ b/web/apps/space/src/data/friends.ts@@ -1,5 +1,5 @@export interface FriendProfile {- avatarObjectKey?: string;+ avatarObjectID?: string;avatarSize?: number;avatarUpdatedAt?: string;avatarUrl?: string | null;@@ -8,7 +8,7 @@ export interface FriendProfile {fullName: string;id: string;username: string;- coverObjectKey?: string;+ coverObjectID?: string;coverUpdatedAt?: string;spaceId?: string;spaceSlug?: string;diff --git a/web/apps/space/src/pages/app/friends/[spaceId].tsx b/web/apps/space/src/pages/app/friends/[spaceId].tsxindex cd1e67a167..0d34d33e4f 100644--- a/web/apps/space/src/pages/app/friends/[spaceId].tsx+++ b/web/apps/space/src/pages/app/friends/[spaceId].tsx@@ -196,7 +196,7 @@ const Page: React.FC = () => {selectedFriend.avatarUrl ??null,coverUrl: currentSelectedProfile?.coverUrl ?? null,- coverObjectKey: currentSelectedProfile?.coverObjectKey,+ coverObjectID: currentSelectedProfile?.coverObjectID,coverUpdatedAt: currentSelectedProfile?.coverUpdatedAt,fullName:currentSelectedProfile?.fullName ??diff --git a/web/apps/space/src/screens/FriendsScreen.tsx b/web/apps/space/src/screens/FriendsScreen.tsxindex 02b7fc1a2d..b5f3ddd90c 100644--- a/web/apps/space/src/screens/FriendsScreen.tsx+++ b/web/apps/space/src/screens/FriendsScreen.tsx@@ -31,7 +31,7 @@ const friendAvatarLoadRootMargin = "800px 0px";const friendAvatarCacheKey = (friend: FriendProfile) =>[friend.id,- friend.avatarObjectKey ?? "",+ friend.avatarObjectID ?? "",friend.avatarUpdatedAt ?? "",friend.avatarSize ?? "",].join(":");@@ -69,7 +69,7 @@ const FriendRow: React.FC<FriendRowProps> = ({const displayName = friend.fullName.trim() || friend.username.trim();const avatarRef = React.useRef<HTMLDivElement | null>(null);const [shouldLoadAvatar, setShouldLoadAvatar] = useState(- Boolean(avatarUrl || !friend.avatarObjectKey),+ Boolean(avatarUrl || !friend.avatarObjectID),);const closeActions = () => setActionsAnchor(null);@@ -84,7 +84,7 @@ const FriendRow: React.FC<FriendRowProps> = ({}, [avatarUrl]);React.useEffect(() => {- if (shouldLoadAvatar || avatarUrl || !friend.avatarObjectKey) return;+ if (shouldLoadAvatar || avatarUrl || !friend.avatarObjectID) return;const element = avatarRef.current;if (!element) return;if (@@ -106,14 +106,14 @@ const FriendRow: React.FC<FriendRowProps> = ({);observer.observe(element);return () => observer.disconnect();- }, [avatarUrl, friend.avatarObjectKey, shouldLoadAvatar]);+ }, [avatarUrl, friend.avatarObjectID, shouldLoadAvatar]);React.useEffect(() => {- if (!shouldLoadAvatar || avatarUrl || !friend.avatarObjectKey) return;+ if (!shouldLoadAvatar || avatarUrl || !friend.avatarObjectID) return;void onLoadAvatar?.().catch((error: unknown) => {console.warn("Failed to load friend avatar", error);});- }, [avatarUrl, friend.avatarObjectKey, onLoadAvatar, shouldLoadAvatar]);+ }, [avatarUrl, friend.avatarObjectID, onLoadAvatar, shouldLoadAvatar]);return (<Box@@ -169,7 +169,7 @@ const FriendRow: React.FC<FriendRowProps> = ({width: 48,}}>- {avatarUrl || !friend.avatarObjectKey ? (+ {avatarUrl || !friend.avatarObjectID ? (<SpaceAvatarImage src={avatarUrl} />) : (<Skeleton@@ -353,7 +353,7 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({(friend: FriendProfile) => {const loadedAvatarUrl = loadedAvatarURLFor(friend);if (loadedAvatarUrl) return Promise.resolve(loadedAvatarUrl);- if (!friend.avatarObjectKey || !onLoadFriendAvatar) {+ if (!friend.avatarObjectID || !onLoadFriendAvatar) {return Promise.resolve(undefined);}diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsxindex 549fa0452e..138369171d 100644--- a/web/apps/space/src/screens/HomeScreen.tsx+++ b/web/apps/space/src/screens/HomeScreen.tsx@@ -228,7 +228,7 @@ const feedPostImageCacheKey = (item: SpacePost) =>const feedPostAvatarCacheKey = (item: SpacePost) =>[item.spaceId,- item.avatarObjectKey ?? "",+ item.avatarObjectID ?? "",item.avatarUpdatedAt ?? "",item.avatarSize ?? "",].join(":");@@ -1389,7 +1389,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({const loadedFeedAvatarURLFor = React.useCallback((item: SpacePost) => {if (item.avatarUrl) return item.avatarUrl;- if (!item.avatarObjectKey) return null;+ if (!item.avatarObjectID) return null;return loadedFeedAvatarURLsByKey[feedPostAvatarCacheKey(item)];},[loadedFeedAvatarURLsByKey],@@ -1433,7 +1433,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({if (loadedAvatarUrl !== undefined) {return Promise.resolve(loadedAvatarUrl);}- if (!item.avatarObjectKey || !onLoadPostAvatar) {+ if (!item.avatarObjectID || !onLoadPostAvatar) {return Promise.resolve(null);}@@ -1808,7 +1808,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({}}>{profile &&- (profile.avatarUrl || !profile.avatarObjectKey) ? (+ (profile.avatarUrl || !profile.avatarObjectID) ? (<SpaceAvatarImagesrc={profile.avatarUrl}borderRadius="50%"diff --git a/web/apps/space/src/screens/ProfileImageViewerScreen.tsx b/web/apps/space/src/screens/ProfileImageViewerScreen.tsxindex 8d88e000cc..35e5135ca0 100644--- a/web/apps/space/src/screens/ProfileImageViewerScreen.tsx+++ b/web/apps/space/src/screens/ProfileImageViewerScreen.tsx@@ -35,9 +35,9 @@ export const ProfileImageViewerScreen: React.FC<? "Change cover image": "Change profile picture";const imageUrl = isCover ? profile.coverUrl : profile.avatarUrl;- const isCoverURLPending = isCover && Boolean(profile.coverObjectKey);+ const isCoverURLPending = isCover && Boolean(profile.coverObjectID);const isAvatarURLPending =- !isCover && Boolean(profile.avatarObjectKey) && !imageUrl;+ !isCover && Boolean(profile.avatarObjectID) && !imageUrl;const displayImageUrl =isCover && !imageUrl? isCoverURLPendingdiff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsxindex e05af2e0c1..bc7e9b9001 100644--- a/web/apps/space/src/screens/ProfileScreen.tsx+++ b/web/apps/space/src/screens/ProfileScreen.tsx@@ -562,7 +562,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({const isFriendProfile = headerVariant == "friend";const displayName = profile.fullName.trim() || profile.username.trim();const coverUrl = profile.coverUrl ?? null;- const isCoverURLPending = Boolean(profile.coverObjectKey && !coverUrl);+ const isCoverURLPending = Boolean(profile.coverObjectID && !coverUrl);const coverImageUrl = coverUrl? coverUrl: isCoverURLPending@@ -1277,7 +1277,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({},}}>- {profile.avatarUrl || !profile.avatarObjectKey ? (+ {profile.avatarUrl || !profile.avatarObjectID ? (<SpaceAvatarImage src={profile.avatarUrl} />) : (<Skeletondiff --git a/web/apps/space/src/screens/SetupProfileScreen.tsx b/web/apps/space/src/screens/SetupProfileScreen.tsxindex d6e7ef85ce..9dcd8665fb 100644--- a/web/apps/space/src/screens/SetupProfileScreen.tsx+++ b/web/apps/space/src/screens/SetupProfileScreen.tsx@@ -24,10 +24,10 @@ const setupProfileFormID = "space-setup-profile-form";export interface SetupProfile {avatarUrl: string | null;- avatarObjectKey?: string;+ avatarObjectID?: string;avatarUpdatedAt?: string;coverUrl?: string | null;- coverObjectKey?: string;+ coverObjectID?: string;coverUpdatedAt?: string;fullName: string;username: string;diff --git a/web/apps/space/src/screens/ShareProfileLinkScreen.tsx b/web/apps/space/src/screens/ShareProfileLinkScreen.tsxindex de388afdd5..48b26ec225 100644--- a/web/apps/space/src/screens/ShareProfileLinkScreen.tsx+++ b/web/apps/space/src/screens/ShareProfileLinkScreen.tsx@@ -131,7 +131,7 @@ export const ShareProfileLinkScreen: React.FC<ShareProfileLinkScreenProps> = ({width: 176,}}>- {profile.avatarUrl || !profile.avatarObjectKey ? (+ {profile.avatarUrl || !profile.avatarObjectID ? (<SpaceAvatarImage src={profile.avatarUrl} />) : (<Skeletondiff --git a/web/apps/space/src/services/space.ts b/web/apps/space/src/services/space.tsindex 2af62bdba8..78ca1b55a8 100644--- a/web/apps/space/src/services/space.ts+++ b/web/apps/space/src/services/space.ts@@ -11,7 +11,7 @@ import { normalizeSpaceMessageText } from "utils/spaceMessageLimits";const currentFeedPageSize = 10;interface SpaceAvatar {- objectKey: string;+ objectID: string;size?: number;updatedAt?: string;}@@ -160,7 +160,7 @@ interface SpaceMessageConversationPageResponse {}interface SpacePostBase {- avatarObjectKey?: string;+ avatarObjectID?: string;avatarSize?: number;avatarUpdatedAt?: string;avatarUrl?: string | null;@@ -409,7 +409,7 @@ const actorProfile = (actor: SpaceActor): FriendProfile => {const username = actor.spaceSlug;return {- avatarObjectKey: actor.avatar?.objectKey,+ avatarObjectID: actor.avatar?.objectID,avatarSize: actor.avatar?.size,avatarUpdatedAt: actor.avatar?.updatedAt,avatarUrl: null,@@ -432,11 +432,11 @@ const profileFromSpaceProfile = (spaceProfile.spaceSlug;return {- avatarObjectKey: spaceProfile.avatar?.objectKey,+ avatarObjectID: spaceProfile.avatar?.objectID,avatarSize: spaceProfile.avatar?.size,avatarUpdatedAt: spaceProfile.avatar?.updatedAt,avatarUrl: null,- coverObjectKey: spaceProfile.cover?.objectKey,+ coverObjectID: spaceProfile.cover?.objectID,coverUpdatedAt: spaceProfile.cover?.updatedAt,coverUrl: null,friendsCount: spaceProfile.friends ?? 0,@@ -453,17 +453,17 @@ const accountCoverURL = async (spaceId: string | undefined,cover: SpaceCover | undefined,) => {- if (!spaceId || !cover?.objectKey) return null;+ if (!spaceId || !cover?.objectID) return null;try {return await cachedBlobURL(["cover",spaceId,- cover.objectKey,+ cover.objectID,cover.updatedAt ?? "",cover.size ?? "",].join(":"),- () => ctx.download_space_cover(spaceId, cover.objectKey),+ () => ctx.download_space_cover(spaceId, cover.objectID),);} catch (error) {console.warn("Failed to load space cover", error);@@ -476,17 +476,17 @@ const accountAvatarURL = async (spaceId: string | undefined,avatar: SpaceAvatar | undefined,) => {- if (!spaceId || !avatar?.objectKey) return null;+ if (!spaceId || !avatar?.objectID) return null;try {return await cachedBlobURL(["avatar",spaceId,- avatar.objectKey,+ avatar.objectID,avatar.updatedAt ?? "",avatar.size ?? "",].join(":"),- () => ctx.download_space_avatar(spaceId, avatar.objectKey),+ () => ctx.download_space_avatar(spaceId, avatar.objectID),);} catch (error) {console.warn("Failed to load space avatar", error);@@ -606,7 +606,7 @@ const postFromAccountPost = async (? await accountPostAssetURL(ctx, post, object): undefined;return {- avatarObjectKey: author.avatarObjectKey,+ avatarObjectID: author.avatarObjectID,avatarSize: author.avatarSize,avatarUpdatedAt: author.avatarUpdatedAt,avatarUrl: author.avatarUrl,@@ -632,7 +632,7 @@ const profilePostFromPost = (const author = actorProfile(post.author);return {- avatarObjectKey: author.avatarObjectKey,+ avatarObjectID: author.avatarObjectID,avatarSize: author.avatarSize,avatarUpdatedAt: author.avatarUpdatedAt,avatarUrl: null,@@ -985,12 +985,12 @@ export const loadCurrentSpacePostAssetURL: SpacePostAssetURLLoader = async (export const loadCurrentSpacePostAvatarURL: SpacePostAvatarURLLoader = async (post,) => {- if (!post.spaceId || !post.avatarObjectKey) return null;+ if (!post.spaceId || !post.avatarObjectID) return null;const ctx = await ensureCurrentSpaceContext();try {return await accountAvatarURL(ctx, post.spaceId, {- objectKey: post.avatarObjectKey,+ objectID: post.avatarObjectID,size: post.avatarSize,updatedAt: post.avatarUpdatedAt,});@@ -1002,12 +1002,12 @@ export const loadCurrentSpacePostAvatarURL: SpacePostAvatarURLLoader = async (export const loadCurrentFriendAvatarURL = async (friend: FriendProfile,): Promise<string | null> => {- if (!friend.spaceId || !friend.avatarObjectKey) return null;+ if (!friend.spaceId || !friend.avatarObjectID) return null;const ctx = await ensureCurrentSpaceContext();try {return await accountAvatarURL(ctx, friend.spaceId, {- objectKey: friend.avatarObjectKey,+ objectID: friend.avatarObjectID,size: friend.avatarSize,updatedAt: friend.avatarUpdatedAt,});diff --git a/web/apps/space/src/services/spaceProfile.ts b/web/apps/space/src/services/spaceProfile.tsindex 95789e0a81..0aad6d919b 100644--- a/web/apps/space/src/services/spaceProfile.ts+++ b/web/apps/space/src/services/spaceProfile.ts@@ -18,7 +18,7 @@ const minUsernameLength = 3;const maxUsernameLength = 30;interface SpaceAvatar {- objectKey: string;+ objectID: string;size?: number;updatedAt?: string;}@@ -214,8 +214,8 @@ const avatarURLForRemoteAvatar = async (spaceId: string,avatar: SpaceAvatar | undefined,) => {- if (!avatar?.objectKey) return null;- const bytes = await ctx.download_space_avatar(spaceId, avatar.objectKey);+ if (!avatar?.objectID) return null;+ const bytes = await ctx.download_space_avatar(spaceId, avatar.objectID);return URL.createObjectURL(new Blob([bytes]));};@@ -224,8 +224,8 @@ const coverURLForRemoteCover = async (spaceId: string,cover: SpaceCover | undefined,) => {- if (!cover?.objectKey) return null;- const bytes = await ctx.download_space_cover(spaceId, cover.objectKey);+ if (!cover?.objectID) return null;+ const bytes = await ctx.download_space_cover(spaceId, cover.objectID);return URL.createObjectURL(new Blob([bytes]));};@@ -239,10 +239,10 @@ const profileFromDecryptedSpaceProfile = (spaceProfile.spaceSlug;return {- avatarObjectKey: spaceProfile.avatar?.objectKey,+ avatarObjectID: spaceProfile.avatar?.objectID,avatarUpdatedAt: spaceProfile.avatar?.updatedAt,avatarUrl: null,- coverObjectKey: spaceProfile.cover?.objectKey,+ coverObjectID: spaceProfile.cover?.objectID,coverUpdatedAt: spaceProfile.cover?.updatedAt,coverUrl: null,fullName,@@ -268,16 +268,16 @@ export const loadExistingSpaceProfile = async () => {export const loadExistingSpaceAvatar = async (spaceId: string | undefined,- avatarObjectKey: string | undefined,+ avatarObjectID: string | undefined,) => {- if (!spaceId || !avatarObjectKey) return null;+ if (!spaceId || !avatarObjectID) return null;const ctx = await openCurrentSpaceContext();if (!ctx) return null;try {return await avatarURLForRemoteAvatar(ctx, spaceId, {- objectKey: avatarObjectKey,+ objectID: avatarObjectID,});} finally {ctx.free();@@ -286,16 +286,16 @@ export const loadExistingSpaceAvatar = async (export const loadExistingSpaceCover = async (spaceId: string | undefined,- coverObjectKey: string | undefined,+ coverObjectID: string | undefined,) => {- if (!spaceId || !coverObjectKey) return null;+ if (!spaceId || !coverObjectID) return null;const ctx = await openCurrentSpaceContext();if (!ctx) return null;try {return await coverURLForRemoteCover(ctx, spaceId, {- objectKey: coverObjectKey,+ objectID: coverObjectID,});} finally {ctx.free();@@ -390,13 +390,13 @@ export const saveSpaceProfile = async (}return {- avatarObjectKey:- updateResponse?.avatar?.objectKey ?? profile.avatarObjectKey,+ avatarObjectID:+ updateResponse?.avatar?.objectID ?? profile.avatarObjectID,avatarUpdatedAt:updateResponse?.avatar?.updatedAt ?? profile.avatarUpdatedAt,avatarUrl,- coverObjectKey:- updateResponse?.cover?.objectKey ?? profile.coverObjectKey,+ coverObjectID:+ updateResponse?.cover?.objectID ?? profile.coverObjectID,coverUpdatedAt:updateResponse?.cover?.updatedAt ?? profile.coverUpdatedAt,coverUrl,diff --git a/web/apps/space/src/state/SpaceAppStateProvider.tsx b/web/apps/space/src/state/SpaceAppStateProvider.tsxindex 7a5d495b28..119d17dcca 100644--- a/web/apps/space/src/state/SpaceAppStateProvider.tsx+++ b/web/apps/space/src/state/SpaceAppStateProvider.tsx@@ -82,7 +82,7 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({const loadProfileAvatar = useCallback(async (profileToHydrate: SetupProfile | null, generation: number) => {if (- !profileToHydrate?.avatarObjectKey ||+ !profileToHydrate?.avatarObjectID ||profileToHydrate.avatarUrl) {return;@@ -91,7 +91,7 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({try {const avatarUrl = await loadExistingSpaceAvatar(profileToHydrate.spaceId,- profileToHydrate.avatarObjectKey,+ profileToHydrate.avatarObjectID,);if (!avatarUrl) return;@@ -100,8 +100,8 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({profileLoadGenerationRef.current != generation ||!currentProfile ||currentProfile.spaceId != profileToHydrate.spaceId ||- currentProfile.avatarObjectKey !=- profileToHydrate.avatarObjectKey+ currentProfile.avatarObjectID !=+ profileToHydrate.avatarObjectID) {URL.revokeObjectURL(avatarUrl);return;@@ -117,17 +117,14 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({const loadProfileCover = useCallback(async (profileToHydrate: SetupProfile | null, generation: number) => {- if (- !profileToHydrate?.coverObjectKey ||- profileToHydrate.coverUrl- ) {+ if (!profileToHydrate?.coverObjectID || profileToHydrate.coverUrl) {return;}try {const coverUrl = await loadExistingSpaceCover(profileToHydrate.spaceId,- profileToHydrate.coverObjectKey,+ profileToHydrate.coverObjectID,);if (!coverUrl) return;@@ -136,8 +133,8 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({profileLoadGenerationRef.current != generation ||!currentProfile ||currentProfile.spaceId != profileToHydrate.spaceId ||- currentProfile.coverObjectKey !=- profileToHydrate.coverObjectKey+ currentProfile.coverObjectID !=+ profileToHydrate.coverObjectID) {URL.revokeObjectURL(coverUrl);return;