π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Simplify Space home actions and restore rounded controls
Anand Baburajane5212734d051
diff --git a/web/apps/space/src/components/AddFriendButton.tsx b/web/apps/space/src/components/AddFriendButton.tsxnew file mode 100644index 0000000000..c0576aef76--- /dev/null+++ b/web/apps/space/src/components/AddFriendButton.tsx@@ -0,0 +1,29 @@+import { UserAdd02Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import { Box } from "@mui/material";+import React from "react";+import { spaceEmptyStateButtonSx } from "styles/buttons";+import { spaceSurface, spaceSurfaceHover } from "styles/colors";++export const SpaceAddFriendButton: React.FC<{ onClick: () => void }> = ({+ onClick,+}) => (+ <Box+ component="button"+ type="button"+ aria-label="Add friend"+ onClick={onClick}+ sx={{+ ...spaceEmptyStateButtonSx,+ bgcolor: spaceSurface,+ borderRadius: "50%",+ color: "#65656D",+ height: 64,+ p: 0,+ width: 64,+ "&:hover:not(:disabled)": { bgcolor: spaceSurfaceHover },+ }}+ >+ <HugeiconsIcon icon={UserAdd02Icon} size={28} strokeWidth={1.7} />+ </Box>+);diff --git a/web/apps/space/src/components/HomeHeader.tsx b/web/apps/space/src/components/HomeHeader.tsxindex 8f32d6a86b..b362e6b564 100644--- a/web/apps/space/src/components/HomeHeader.tsx+++ b/web/apps/space/src/components/HomeHeader.tsx@@ -64,7 +64,7 @@ export const SpaceHomeHeader: React.FC<SpaceHomeHeaderProps> = ({zIndex: 4,"&::after": {bgcolor: spaceSurface,- borderRadius: "16px",+ borderRadius: "999px",content: '""',height: 44,left: "16px",diff --git a/web/apps/space/src/components/NewPostButton.tsx b/web/apps/space/src/components/NewPostButton.tsxindex c089fb137b..b61a31db6e 100644--- a/web/apps/space/src/components/NewPostButton.tsx+++ b/web/apps/space/src/components/NewPostButton.tsx@@ -6,9 +6,6 @@ import { useSpaceAppState } from "state/app-state";const green = "#08C225";-export const spaceNewPostButtonSize = 48;-export const spaceNewPostButtonRadius = 16;-export const SpaceNewPostButton: React.FC<{isDisabled?: boolean;onClick: () => void;@@ -26,19 +23,22 @@ export const SpaceNewPostButton: React.FC<{onClick={onClick}sx={{alignItems: "center",+ alignSelf: "flex-end",appearance: "none",bgcolor: green,border: 0,- borderRadius: `${spaceNewPostButtonRadius}px`,+ borderRadius: "50%",+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.32)",color: "#FFFFFF",cursor: disabled ? "default" : "pointer",display: "flex",flexShrink: 0,- height: spaceNewPostButtonSize,+ height: 64,justifyContent: "center",+ ml: "auto",opacity: disabled ? 0.6 : 1,p: 0,- width: spaceNewPostButtonSize,+ width: 64,"&:hover:not(:disabled)": { bgcolor: "#07B422" },"&:focus-visible": {outline: `2px solid ${green}`,@@ -46,7 +46,7 @@ export const SpaceNewPostButton: React.FC<{},}}>- <HugeiconsIcon icon={Add01Icon} size={28} strokeWidth={2} />+ <HugeiconsIcon icon={Add01Icon} size={32} strokeWidth={2} /></Box>);};diff --git a/web/apps/space/src/components/OwnPostTile.tsx b/web/apps/space/src/components/OwnPostTile.tsxdeleted file mode 100644index 600a6acdd3..0000000000--- a/web/apps/space/src/components/OwnPostTile.tsx+++ /dev/null@@ -1,344 +0,0 @@-import { Image01Icon } from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";-import { Box, Skeleton } from "@mui/material";-import {- SpaceNewPostButton,- spaceNewPostButtonRadius,- spaceNewPostButtonSize,-} from "components/NewPostButton";-import log from "ente-base/log";-import React from "react";-import type { SpacePost, SpacePostAssetURLLoader } from "services/space";-import { useSpaceAppState, type SpacePostPublishPhase } from "state/app-state";-import {- spaceSurface,- spaceSurfaceHover,- spaceText,- spaceTextMuted,-} from "styles/colors";-import { formatSpaceDate } from "utils/display";-import { thumbHashDataURLFromBase64 } from "utils/thumbhash";--const green = "#08C225";-const groupInset = 8;-const groupGap = groupInset * 1.5;-const groupHeight = spaceNewPostButtonSize + groupInset * 2;-const groupRadius = spaceNewPostButtonRadius + groupInset;--const PostTimestamp: React.FC<{- timestampMs: number;- phase?: SpacePostPublishPhase;- expiresAtMs?: number;-}> = ({ timestampMs, phase, expiresAtMs }) => {- const [now, setNow] = React.useState(Date.now);-- React.useEffect(() => {- setNow(Date.now());- const intervalID = window.setInterval(- () => setNow(Date.now()),- phase == "posting" ? 500 : 60_000,- );- const timeoutID = expiresAtMs- ? window.setTimeout(- () => setNow(Date.now()),- Math.max(0, expiresAtMs - Date.now()),- )- : undefined;- return () => {- window.clearInterval(intervalID);- window.clearTimeout(timeoutID);- };- }, [phase, expiresAtMs]);-- const status =- phase && (!expiresAtMs || expiresAtMs > now) ? phase : undefined;- const label =- status == "posting"- ? "Posting"- : status == "posted"- ? "Posted"- : status == "failed"- ? "Failed"- : formatSpaceDate(timestampMs);-- return (- <Box- component="span"- role="status"- aria-label={label}- sx={{- color:- status == "posted"- ? "color(display-p3 0.0314 0.7608 0.1451 / 0.85)"- : status == "failed"- ? "#FF8585"- : spaceTextMuted,- display: "block",- fontSize: 12,- lineHeight: "18px",- }}- >- {status ? (- label- ) : (- <time dateTime={new Date(timestampMs).toISOString()}>- {label}- </time>- )}- {status == "posting" && (- <Box component="span" aria-hidden>- {".".repeat((Math.floor(now / 500) % 3) + 1)}- </Box>- )}- </Box>- );-};--interface SpaceOwnPostTileProps {- post?: SpacePost;- isLoading?: boolean;- isUnavailable?: boolean;- isNewPostDisabled?: boolean;- onLoadPostImage?: SpacePostAssetURLLoader;- onOpenPost?: () => void;- onNewPost: () => void;-}--export const SpaceOwnPostTile: React.FC<SpaceOwnPostTileProps> = ({- post,- isLoading = false,- isUnavailable = false,- isNewPostDisabled = false,- onLoadPostImage,- onOpenPost,- onNewPost,-}) => {- const { postPublication } = useSpaceAppState();- const tileRef = React.useRef<HTMLElement>(null);- const publishPhase =- postPublication?.post == post ? postPublication?.phase : undefined;- const hasPublication = Boolean(publishPhase);- const [loadedImage, setLoadedImage] = React.useState<{- post: SpacePost;- url?: string;- failed?: boolean;- }>();- const postImage = loadedImage?.post == post ? loadedImage : undefined;- const imageUrl = post?.imageUrl ?? postImage?.url;- const thumbHashDataURL = React.useMemo(- () => thumbHashDataURLFromBase64(post?.thumbHash),- [post?.thumbHash],- );- const unavailable =- isUnavailable || post?.isUnavailable || postImage?.failed;- const canOpenPost = Boolean(- post && onOpenPost && (!publishPhase || publishPhase == "posted"),- );- const loading =- isLoading || Boolean(post?.imageAsset && !imageUrl && !unavailable);- const [showSkeleton, setShowSkeleton] = React.useState(false);- const isEmpty = !post && !loading && !unavailable;- const caption = post?.caption?.trim();-- React.useEffect(() => {- setShowSkeleton(false);- if (!loading) return;-- const timeoutID = window.setTimeout(() => setShowSkeleton(true), 200);- return () => window.clearTimeout(timeoutID);- }, [loading]);-- React.useEffect(() => {- if (hasPublication)- tileRef.current?.scrollIntoView({ block: "nearest" });- }, [hasPublication]);-- React.useEffect(() => {- if (!post?.imageAsset || post.imageUrl || !onLoadPostImage) return;-- let cancelled = false;- void onLoadPostImage(post.imageAsset)- .then((url) => {- if (!cancelled) setLoadedImage({ post, url });- })- .catch((error: unknown) => {- log.warn("Failed to load own latest post image", error);- if (!cancelled) setLoadedImage({ post, failed: true });- });- return () => {- cancelled = true;- };- }, [onLoadPostImage, post]);-- return (- <Box- ref={tileRef}- component="section"- aria-label="Your latest post"- sx={{- alignItems: "center",- bgcolor: spaceSurface,- borderRadius: `${groupRadius}px`,- boxSizing: "border-box",- display: "flex",- flexShrink: 0,- fontFamily: '"Inter Variable", Inter, sans-serif',- gap: `${groupGap}px`,- height: groupHeight,- minWidth: 0,- p: `${groupInset}px`,- "& .MuiSkeleton-root": {- visibility: showSkeleton ? "visible" : "hidden",- },- }}- >- <Box- component="button"- type="button"- aria-label="Open your posts"- disabled={!canOpenPost}- onClick={onOpenPost}- sx={{- alignItems: "center",- appearance: "none",- bgcolor: "transparent",- border: 0,- borderRadius: `${spaceNewPostButtonRadius}px`,- color: spaceText,- cursor: canOpenPost ? "pointer" : "default",- display: "flex",- flex: 1,- font: "inherit",- gap: `${groupGap}px`,- minWidth: 0,- p: 0,- textAlign: "left",- "&:focus-visible": {- outline: `2px solid ${green}`,- outlineOffset: 2,- },- }}- >- <Box- component="span"- sx={{- bgcolor: spaceSurfaceHover,- borderRadius: `${spaceNewPostButtonRadius}px`,- display: "grid",- flexShrink: 0,- height: spaceNewPostButtonSize,- overflow: "hidden",- placeItems: "center",- position: "relative",- width: spaceNewPostButtonSize,- }}- >- {isEmpty && (- <HugeiconsIcon- icon={Image01Icon}- size={24}- strokeWidth={1.6}- color={spaceTextMuted}- aria-hidden- />- )}- {thumbHashDataURL && !unavailable && (- <Box- component="img"- alt=""- src={thumbHashDataURL}- sx={{- filter: "blur(8px)",- height: "100%",- inset: 0,- objectFit: "cover",- position: "absolute",- transform: "scale(1.08)",- width: "100%",- }}- />- )}- {imageUrl && !unavailable ? (- <Box- component="img"- alt=""- src={imageUrl}- onError={() =>- post && setLoadedImage({ post, failed: true })- }- sx={{- display: "block",- height: "100%",- objectFit: "cover",- position: "relative",- width: "100%",- }}- />- ) : loading && !thumbHashDataURL ? (- <Skeleton- variant="rectangular"- sx={{ height: "100%", width: "100%" }}- />- ) : null}- </Box>- <Box component="span" sx={{ flex: 1, minWidth: 0 }}>- {post ? (- <PostTimestamp- timestampMs={post.timestampMs}- phase={publishPhase}- expiresAtMs={postPublication?.statusExpiresAtMs}- />- ) : loading ? (- <Skeleton- width={72}- sx={{ fontSize: 12, lineHeight: "18px" }}- />- ) : (- <Box- component="span"- sx={{- color: isEmpty ? spaceText : spaceTextMuted,- display: "block",- fontSize: 12,- fontWeight: 400,- lineHeight: "18px",- whiteSpace: "nowrap",- }}- >- {unavailable- ? "Post unavailable"- : "Share your first post."}- </Box>- )}- <Box- component="span"- title={post ? caption : undefined}- sx={{- color: spaceTextMuted,- display: "block",- fontSize: 12,- fontWeight: 400,- lineHeight: "20px",- opacity: isEmpty ? 1 : 0.65,- overflow: "hidden",- textOverflow: "ellipsis",- whiteSpace: "nowrap",- }}- >- {!post && loading ? (- <Skeleton width="70%" />- ) : isEmpty ? (- "What are you up to?"- ) : post ? (- caption || "No caption"- ) : null}- </Box>- </Box>- </Box>- <SpaceNewPostButton- isDisabled={isNewPostDisabled}- onClick={onNewPost}- />- </Box>- );-};diff --git a/web/apps/space/src/components/PostFloatingActionButton.tsx b/web/apps/space/src/components/PostFloatingActionButton.tsxindex 39e5ccbb1d..b830820c29 100644--- a/web/apps/space/src/components/PostFloatingActionButton.tsx+++ b/web/apps/space/src/components/PostFloatingActionButton.tsx@@ -1,15 +1,12 @@import { Add01Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { Box } from "@mui/material";-import {- spaceNewPostButtonRadius,- spaceNewPostButtonSize,-} from "components/NewPostButton";import React from "react";const green = "#08C225";const paleGreen = "#E7F6E9";-const iconSize = 28;+const buttonSize = 64;+const iconSize = 34;interface SpacePostFloatingActionButtonProps {disabled?: boolean;@@ -31,14 +28,14 @@ export const SpacePostFloatingActionButton: React.FC<appearance: "none",bgcolor: green,border: 0,- borderRadius: `${spaceNewPostButtonRadius}px`,+ borderRadius: "50%",bottom: "calc(env(safe-area-inset-bottom) + 16px)",boxShadow: "0 10px 24px rgba(0, 0, 0, 0.22)",color: "#FFFFFF",cursor: disabled ? "default" : "pointer",display: "flex",fontSize: 0,- height: spaceNewPostButtonSize,+ height: buttonSize,justifyContent: "center",lineHeight: 0,opacity: disabled ? 0.72 : 1,@@ -47,7 +44,7 @@ export const SpacePostFloatingActionButton: React.FC<right: "16px",transition:"background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease",- width: spaceNewPostButtonSize,+ width: buttonSize,zIndex: 5,"@media (min-width: 600px)": {right: "calc((100vw - 390px) / 2 + 16px)",diff --git a/web/apps/space/src/hooks/use-own-latest-post.ts b/web/apps/space/src/hooks/use-own-latest-post.tsdeleted file mode 100644index b857395720..0000000000--- a/web/apps/space/src/hooks/use-own-latest-post.ts+++ /dev/null@@ -1,73 +0,0 @@-import log from "ente-base/log";-import { useEffect, useState } from "react";-import { savedSpaceOwnedSpaces } from "services/persistent-session";-import { loadCachedOwnLatestPost } from "services/post-cache";-import { loadExistingSpaceId } from "services/profile";-import {- loadCurrentSpaceProfilePostsPage,- type SpacePost,-} from "services/space";-import { useSpaceAppState } from "state/app-state";--export const useOwnLatestPost = () => {- const { postPublication } = useSpaceAppState();- const isPublishingPost = postPublication?.phase == "posting";- const [ownLatestPost, setOwnLatestPost] = useState<SpacePost>();- const [isOwnLatestPostLoading, setIsOwnLatestPostLoading] = useState(true);- const [isOwnLatestPostUnavailable, setIsOwnLatestPostUnavailable] =- useState(false);-- useEffect(() => {- setIsOwnLatestPostLoading(true);- setIsOwnLatestPostUnavailable(false);- if (isPublishingPost) return;-- let cancelled = false;- const isCancelled = () => cancelled;- let cachedPost: SpacePost | undefined;- void (async () => {- const cachedSpaceId = savedSpaceOwnedSpaces()?.[0]?.spaceId;- if (cachedSpaceId) {- cachedPost = await loadCachedOwnLatestPost(cachedSpaceId);- if (isCancelled()) return;- if (cachedPost) {- setOwnLatestPost(cachedPost);- setIsOwnLatestPostLoading(false);- }- }-- const spaceId = await loadExistingSpaceId();- if (isCancelled()) return;- if (cachedPost?.spaceId != spaceId) {- cachedPost = undefined;- setOwnLatestPost(undefined);- setIsOwnLatestPostLoading(true);- }- if (!spaceId) return;-- const page = await loadCurrentSpaceProfilePostsPage(- spaceId,- spaceId,- );- if (!isCancelled()) setOwnLatestPost(page.items[0]);- })()- .catch((error: unknown) => {- log.error("Failed to load own latest Space post", error);- if (!cancelled && !cachedPost)- setIsOwnLatestPostUnavailable(true);- })- .finally(() => {- if (!cancelled) setIsOwnLatestPostLoading(false);- });- return () => {- cancelled = true;- };- }, [isPublishingPost]);-- return {- ownLatestPost: postPublication?.post ?? ownLatestPost,- isOwnLatestPostLoading: !postPublication && isOwnLatestPostLoading,- isOwnLatestPostUnavailable:- !postPublication && isOwnLatestPostUnavailable,- };-};diff --git a/web/apps/space/src/pages/app/index.tsx b/web/apps/space/src/pages/app/index.tsxindex e4c41de91e..1bc002ab9e 100644--- a/web/apps/space/src/pages/app/index.tsx+++ b/web/apps/space/src/pages/app/index.tsx@@ -4,7 +4,6 @@ import { SpaceFriendRequestCanceledToast } from "components/FriendRequestCanceleimport { SpacePageMeta } from "components/PageMeta";import { SpaceRouteFallback } from "components/RouteFallback";import log from "ente-base/log";-import { useOwnLatestPost } from "hooks/use-own-latest-post";import React, { useEffect, useState } from "react";import { HomeScreen } from "screens/HomeScreen";import {@@ -62,11 +61,6 @@ const Page: React.FC = () => {);const [latestPosts, setLatestPosts] = useState<SpacePost[]>([]);const [spaceId, setSpaceId] = useState<string>();- const {- ownLatestPost,- isOwnLatestPostLoading,- isOwnLatestPostUnavailable,- } = useOwnLatestPost();const [unreadPosts, setUnreadPosts] = useState<SpacePost[]>([]);const [hasUnreadMessages, setHasUnreadMessages] = useState<boolean>();const [isLatestPostsLoading, setIsLatestPostsLoading] = useState(true);@@ -256,9 +250,6 @@ const Page: React.FC = () => {<><SpacePageMeta themeColor={spaceAppBackgroundColor} /><HomeScreen- ownLatestPost={ownLatestPost}- isOwnLatestPostLoading={isOwnLatestPostLoading}- isOwnLatestPostUnavailable={isOwnLatestPostUnavailable}latestPosts={latestPosts}unreadPosts={unreadPosts}friendRequestSentToastName={friendRequestSentToastName}@@ -423,13 +414,6 @@ const Page: React.FC = () => {);await refreshUnreadStatus(profile.spaceId);}}- onOpenOwnPost={() =>- void router.push(- `${spaceRoutes.profile}?section=latest`,- undefined,- { scroll: false },- )- }onOpenProfile={profile? () => void router.push(spaceRoutes.profile)diff --git a/web/apps/space/src/pages/layout-demo.tsx b/web/apps/space/src/pages/layout-demo.tsxindex 4b12a266bd..a5ca1f2c72 100644--- a/web/apps/space/src/pages/layout-demo.tsx+++ b/web/apps/space/src/pages/layout-demo.tsx@@ -1,11 +1,12 @@import { ArrowLeft02Icon, ArrowRight02Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { Box } from "@mui/material";+import { SpaceAddFriendButton } from "components/AddFriendButton";import { SpaceAddFriendDialog } from "components/AddFriendDialog";import { SpaceAddFriendTile } from "components/AddFriendTile";import { SpaceFileViewer } from "components/FileViewer";import { SpaceHomeHeader, spaceHomeHeaderHeight } from "components/HomeHeader";-import { SpaceOwnPostTile } from "components/OwnPostTile";+import { SpaceNewPostButton } from "components/NewPostButton";import { useBrowserBackClose } from "hooks/use-browser-back-close";import React from "react";import { FriendPostTile } from "screens/HomeScreen";@@ -30,15 +31,6 @@ const demoProfile: SetupProfile = {spaceId: "demo-self",username: "you",};-const demoOwnPost: SpacePost = {- friendID: "demo-self",- imageUrl: spaceDefaultCoverImagePath,- name: demoProfile.fullName,- postId: 100,- spaceId: "demo-self",- timestampMs: 1_700_000_000_000,- viewerLiked: false,-};const singleFriendVariants = ["no-posts",@@ -187,14 +179,10 @@ const LayoutDemoPage: React.FC = () => {Math.max(0, Math.min(maximumHomeTileCount, count + delta)),);}, []);- const [ownPost, setOwnPost] = React.useState<SpacePost>();- const [postPreviewActionMode, setPostPreviewActionMode] = React.useState<- "draft-post" | "hidden"- >();- const isPostPreviewOpen = postPreviewActionMode !== undefined;+ const [isPostPreviewOpen, setIsPostPreviewOpen] = React.useState(false);useBrowserBackClose({open: isPostPreviewOpen,- onClose: () => setPostPreviewActionMode(undefined),+ onClose: () => setIsPostPreviewOpen(false),stateKey: "space-layout-demo-viewer",});const [canvasSize, setCanvasSize] = React.useState<CanvasSize>({@@ -202,6 +190,10 @@ const LayoutDemoPage: React.FC = () => {width: 0,});const canvasRef = React.useRef<HTMLDivElement | null>(null);+ const openAddFriend = () => {+ setProfileLink(spaceInviteURL({ spaceUsername: demoProfile.username }));+ setIsAddFriendOpen(true);+ };React.useEffect(() => {const canvas = canvasRef.current;@@ -377,25 +369,27 @@ const LayoutDemoPage: React.FC = () => {<SpaceAddFriendTileplacement={layout.addFriend}variant={layout.addFriendVariant}- onClick={() => {- setProfileLink(- spaceInviteURL({- spaceUsername:- demoProfile.username,- }),- );- setIsAddFriendOpen(true);- }}+ onClick={openAddFriend}/>)}</>)}</Box>- <SpaceOwnPostTile- post={ownPost}- onNewPost={() => setPostPreviewActionMode("draft-post")}- onOpenPost={() => setPostPreviewActionMode("hidden")}- />+ <Box+ sx={{+ alignItems: "center",+ display: "flex",+ gap: `${homeTileGap}px`,+ justifyContent: "flex-end",+ }}+ >+ {[1, 2, 4, 6, 8].includes(friendCount) && (+ <SpaceAddFriendButton onClick={openAddFriend} />+ )}+ <SpaceNewPostButton+ onClick={() => setIsPostPreviewOpen(true)}+ />+ </Box></Box><SpaceAddFriendDialogfriendRequests={[]}@@ -412,21 +406,15 @@ const LayoutDemoPage: React.FC = () => {{isPostPreviewOpen && (<SpaceFileViewerphoto={{- ...(ownPost ?? demoOwnPost),alt: "Your post",avatarUrl: demoProfile.avatarUrl,imageUrl: spaceDefaultCoverImagePath,+ name: demoProfile.fullName,+ timestampMs: 1_700_000_000_000,}}- postActionMode={postPreviewActionMode}- onClose={() => setPostPreviewActionMode(undefined)}- onPublishDraftPost={(caption) => {- setOwnPost({- ...demoOwnPost,- caption,- timestampMs: Date.now(),- });- return Promise.resolve();- }}+ postActionMode="draft-post"+ onClose={() => setIsPostPreviewOpen(false)}+ onPublishDraftPost={() => Promise.resolve()}/>)}</Box>diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsxindex ad5a9ed245..83c03b6e14 100644--- a/web/apps/space/src/screens/HomeScreen.tsx+++ b/web/apps/space/src/screens/HomeScreen.tsx@@ -6,6 +6,7 @@ import {SpaceActionToast,spaceToastAutoDismissDurationMs,} from "components/ActionToast";+import { SpaceAddFriendButton } from "components/AddFriendButton";import { SpaceAddFriendTile } from "components/AddFriendTile";import { SpaceAvatarImage } from "components/AvatarImage";import {@@ -17,7 +18,7 @@ import {import { FriendQuickActionsDialog } from "components/FriendQuickActionsDialog";import { FriendTilePokeButton } from "components/FriendTilePokeButton";import { SpaceHomeHeader, spaceHomeHeaderHeight } from "components/HomeHeader";-import { SpaceOwnPostTile } from "components/OwnPostTile";+import { SpaceNewPostButton } from "components/NewPostButton";import {SpacePostBadge,SpacePostUnreadBadge,@@ -79,9 +80,6 @@ const tileBadgeText = "rgba(255, 255, 255, 0.9)";const homeHorizontalPadding = "16px";const postTileMediaLoadRootMargin = "640px 0px";interface HomeScreenProps {- ownLatestPost?: SpacePost;- isOwnLatestPostLoading?: boolean;- isOwnLatestPostUnavailable?: boolean;latestPosts: SpacePost[];unreadPosts: SpacePost[];friendRequestSentToastName?: string;@@ -112,7 +110,6 @@ interface HomeScreenProps {onOpenMessages?: () => void;onMessageFriend: (friend: FriendProfile) => void;onPokeFriend: (friend: FriendProfile) => Promise<void>;- onOpenOwnPost?: () => void;onOpenProfile?: () => void;onReplyToPost?: (postSpaceId: string,@@ -1003,9 +1000,6 @@ const AddedFriendToast: React.FC<AddedFriendToastProps> = ({);export const HomeScreen: React.FC<HomeScreenProps> = ({- ownLatestPost,- isOwnLatestPostLoading = false,- isOwnLatestPostUnavailable = false,latestPosts,unreadPosts,friendRequestSentToastName,@@ -1029,7 +1023,6 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({onOpenMessages,onMessageFriend,onPokeFriend,- onOpenOwnPost,onOpenProfile,onReplyToPost,onSetPostLiked,@@ -1757,15 +1750,23 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({))}</Box>- <SpaceOwnPostTile- post={ownLatestPost}- isLoading={isOwnLatestPostLoading}- isUnavailable={isOwnLatestPostUnavailable}- isNewPostDisabled={isPostPhotoButtonDisabled}- onLoadPostImage={onLoadPostImage}- onNewPost={openPostPhotoPicker}- onOpenPost={onOpenOwnPost}- />+ <Box+ sx={{+ alignItems: "center",+ display: "flex",+ gap: `${homeTileGap}px`,+ justifyContent: "flex-end",+ }}+ >+ {!isHomeItemsLoading &&+ [1, 2, 4, 6, 8].includes(+ orderedHomeItems.length,+ ) && <SpaceAddFriendButton onClick={onAddFriend} />}+ <SpaceNewPostButton+ isDisabled={isPostPhotoButtonDisabled}+ onClick={openPostPhotoPicker}+ />+ </Box></Box>{selectedContact && (<FriendQuickActionsDialogdiff --git a/web/apps/space/src/services/post-cache.ts b/web/apps/space/src/services/post-cache.tsindex f20b9f64a8..423f0187df 100644--- a/web/apps/space/src/services/post-cache.ts+++ b/web/apps/space/src/services/post-cache.ts@@ -1,8 +1,3 @@-import { savedPartialLocalUser } from "ente-accounts/services/accounts-db";-import { getKV, removeKV, setKV } from "ente-base/kv";-import log from "ente-base/log";-import { apiOrigin } from "ente-base/origins";-import type { SpacePost } from "services/space";import { z } from "zod";const CachedSpacePostAsset = z.object({@@ -33,55 +28,3 @@ export const CachedSpacePost = z.object({viewerLiked: z.boolean(),width: z.number().optional(),});--const ownLatestPostKey = async (spaceId: string) => {- const userID = savedPartialLocalUser()?.id;- if (!userID) return undefined;- return [- "space-own-latest-post",- "v1",- await apiOrigin(),- userID,- spaceId,- ].join(":");-};--export const loadCachedOwnLatestPost = async (spaceId: string) => {- try {- const key = await ownLatestPostKey(spaceId);- if (!key) return undefined;- const parsed = CachedSpacePost.safeParse(await getKV(key));- return parsed.success ? parsed.data : undefined;- } catch (error) {- log.warn("Failed to read own latest Space post cache", error);- return undefined;- }-};--export const cacheOwnLatestPost = async (- spaceId: string,- post: SpacePost | undefined,-) => {- try {- const key = await ownLatestPostKey(spaceId);- if (!key) return;- if (post) await setKV(key, CachedSpacePost.parse(post));- else await removeKV(key);- } catch (error) {- log.warn("Failed to persist own latest Space post cache", error);- }-};--export const patchCachedOwnLatestPost = async (- spaceId: string,- postId: number,- patch: Partial<SpacePost> | undefined,-) => {- const post = await loadCachedOwnLatestPost(spaceId);- if (post?.postId == postId) {- await cacheOwnLatestPost(- spaceId,- patch ? { ...post, ...patch } : undefined,- );- }-};diff --git a/web/apps/space/src/services/space.ts b/web/apps/space/src/services/space.tsindex f55a0b211a..6bebe3bd9d 100644--- a/web/apps/space/src/services/space.ts+++ b/web/apps/space/src/services/space.ts@@ -18,10 +18,6 @@ import {spacePostMediaCacheKey,spaceProfileMediaCacheKey,} from "services/media-cache";-import {- cacheOwnLatestPost,- patchCachedOwnLatestPost,-} from "services/post-cache";import {ensureCurrentSpaceContext,loadExistingSpaceProfile,@@ -1223,7 +1219,7 @@ export const loadCurrentSpaceProfilePostsPage = async (): Promise<SpaceProfilePostPage> => {const ctx = await ensureCurrentSpaceContext();try {- const page = profilePostPageFromPage(+ return profilePostPageFromPage((await ctx.listPosts(spaceId,viewerSpaceId ?? null,@@ -1231,10 +1227,6 @@ export const loadCurrentSpaceProfilePostsPage = async (60,)) as SpacePostPageResponse,);- if (!cursor && spaceId == viewerSpaceId) {- await cacheOwnLatestPost(spaceId, page.items[0]);- }- return page;} finally {releaseCurrentSpaceContext(ctx);}@@ -1374,9 +1366,7 @@ export const createCurrentPhotoPost = async ({)) as SpacePostResponse;const object = firstObject(created);if (object) await cacheAccountPostAssetURL(created, object, file);- const post = await postFromAccountPost(ctx, created, true, spaceId);- await cacheOwnLatestPost(spaceId, post);- return post;+ return await postFromAccountPost(ctx, created, true, spaceId);} finally {releaseCurrentSpaceContext(ctx);}@@ -1726,7 +1716,6 @@ export const deleteCurrentPost = async (spaceId: string, postId: number) => {const ctx = await ensureCurrentSpaceContext();try {await ctx.deletePost(spaceId, BigInt(postId));- await patchCachedOwnLatestPost(spaceId, postId, undefined);} finally {releaseCurrentSpaceContext(ctx);}@@ -1744,9 +1733,6 @@ export const updateCurrentPostCaption = async (BigInt(postId),caption.trim() || null,);- await patchCachedOwnLatestPost(spaceId, postId, {- caption: caption.trim() || undefined,- });} finally {releaseCurrentSpaceContext(ctx);}diff --git a/web/apps/space/src/state/AppStateProvider.tsx b/web/apps/space/src/state/AppStateProvider.tsxindex fdffc096e6..20e3b3eed9 100644--- a/web/apps/space/src/state/AppStateProvider.tsx+++ b/web/apps/space/src/state/AppStateProvider.tsx@@ -36,8 +36,6 @@ import {} from "state/app-state";import { prepareSpacePostImageFromEdit } from "utils/post-image";-const postStatusDurationMs = 2000;-export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({children,}) => {@@ -152,7 +150,6 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({...publication,phase: "posted",post,- statusExpiresAtMs: Date.now() + postStatusDurationMs,});}return post;diff --git a/web/apps/space/src/state/app-state.tsx b/web/apps/space/src/state/app-state.tsxindex f01b80bfc9..9aa7dd61f3 100644--- a/web/apps/space/src/state/app-state.tsx+++ b/web/apps/space/src/state/app-state.tsx@@ -17,7 +17,6 @@ export interface SpacePostPublication {phase: SpacePostPublishPhase;post: SpacePost;previewUrl: string;- statusExpiresAtMs?: number;}export type PendingCreateProfile = SetupProfileDetails & {source: CreateProfileSource;diff --git a/web/apps/space/tests/post-cache.test.ts b/web/apps/space/tests/post-cache.test.tsdeleted file mode 100644index 18eaecf3c4..0000000000--- a/web/apps/space/tests/post-cache.test.ts+++ /dev/null@@ -1,103 +0,0 @@-import { savedPartialLocalUser } from "ente-accounts/services/accounts-db";-import { getKV, removeKV, setKV } from "ente-base/kv";-import { apiOrigin } from "ente-base/origins";-import { beforeEach, expect, test, vi } from "vitest";-import {- cacheOwnLatestPost,- loadCachedOwnLatestPost,- patchCachedOwnLatestPost,-} from "../src/services/post-cache";-import type { SpacePost } from "../src/services/space";--vi.mock("ente-accounts/services/accounts-db", () => ({- savedPartialLocalUser: vi.fn(),-}));-vi.mock("ente-base/kv", () => ({- getKV: vi.fn(),- setKV: vi.fn(),- removeKV: vi.fn(),-}));-vi.mock("ente-base/log", () => ({ default: { warn: vi.fn() } }));-vi.mock("ente-base/origins", () => ({ apiOrigin: vi.fn() }));--const storage = new Map<string, unknown>();-const post: SpacePost = {- avatarUrl: "blob:avatar",- caption: "A photo",- friendID: "self",- imageAsset: {- encryptedPostKey: "encrypted-key",- keyVersion: 1,- objectKey: "photo",- postId: 1,- spaceId: "self",- },- imageUrl: "blob:photo",- name: "Me",- postId: 1,- spaceId: "self",- thumbHash: "3OcRJYB4d3h/iIeHeEh3eIhw+j3A",- timestampMs: 1,- viewerLiked: false,-};--beforeEach(() => {- vi.resetAllMocks();- storage.clear();- vi.mocked(savedPartialLocalUser).mockReturnValue({ id: 1 });- vi.mocked(apiOrigin).mockResolvedValue("https://api.example.com");- vi.mocked(getKV).mockImplementation((key) =>- Promise.resolve(storage.get(key)),- );- vi.mocked(setKV).mockImplementation((key, value) => {- storage.set(key, structuredClone(value));- return Promise.resolve();- });- vi.mocked(removeKV).mockImplementation((key) => {- storage.delete(key);- return Promise.resolve();- });-});--test("restores the hash and image asset without expired blob URLs", async () => {- await cacheOwnLatestPost("self", post);- const restored = await loadCachedOwnLatestPost("self");- expect(restored?.thumbHash).toBe(post.thumbHash);- expect(restored?.imageAsset).toEqual(post.imageAsset);- expect(restored).not.toHaveProperty("imageUrl");- expect(restored).not.toHaveProperty("avatarUrl");-});--test("keeps previews separate across spaces, accounts, and servers", async () => {- await cacheOwnLatestPost("self", post);- expect(await loadCachedOwnLatestPost("another-space")).toBeUndefined();- vi.mocked(savedPartialLocalUser).mockReturnValue({ id: 2 });- expect(await loadCachedOwnLatestPost("self")).toBeUndefined();- vi.mocked(savedPartialLocalUser).mockReturnValue({ id: 1 });- vi.mocked(apiOrigin).mockResolvedValue("https://other.example.com");- expect(await loadCachedOwnLatestPost("self")).toBeUndefined();-});--test("updates captions and removes deleted posts without clearing newer posts", async () => {- await cacheOwnLatestPost("self", post);- await patchCachedOwnLatestPost("self", 1, { caption: "Edited" });- expect((await loadCachedOwnLatestPost("self"))?.caption).toBe("Edited");- await cacheOwnLatestPost("self", { ...post, postId: 2 });- await patchCachedOwnLatestPost("self", 1, undefined);- expect((await loadCachedOwnLatestPost("self"))?.postId).toBe(2);- await patchCachedOwnLatestPost("self", 2, undefined);- expect(await loadCachedOwnLatestPost("self")).toBeUndefined();-});--test("clears the preview when the refreshed profile has no posts", async () => {- await cacheOwnLatestPost("self", post);- await cacheOwnLatestPost("self", undefined);- expect(await loadCachedOwnLatestPost("self")).toBeUndefined();-});--test("a cache failure does not fail the post operation", async () => {- vi.mocked(setKV).mockRejectedValue(new Error("Storage unavailable"));- await expect(cacheOwnLatestPost("self", post)).resolves.toBeUndefined();- vi.mocked(getKV).mockRejectedValue(new Error("Storage unavailable"));- await expect(loadCachedOwnLatestPost("self")).resolves.toBeUndefined();-});