Skip to content

armgit / ente

Public Imported from GitHub
0

💚 End-to-end encrypted cloud for everything.

Restore and refine Space latest post controls

Anand Baburajanc388805158e6
diff --git a/web/apps/space/src/components/HomeHeader.tsx b/web/apps/space/src/components/HomeHeader.tsx
index b362e6b564..8f32d6a86b 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: "999px",
+ borderRadius: "16px",
content: '""',
height: 44,
left: "16px",
diff --git a/web/apps/space/src/components/NewPostButton.tsx b/web/apps/space/src/components/NewPostButton.tsx
index 06a98bda25..c089fb137b 100644
--- a/web/apps/space/src/components/NewPostButton.tsx
+++ b/web/apps/space/src/components/NewPostButton.tsx
@@ -6,6 +6,9 @@ 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;
@@ -23,21 +26,19 @@ export const SpaceNewPostButton: React.FC<{
onClick={onClick}
sx={{
alignItems: "center",
- alignSelf: "flex-end",
appearance: "none",
bgcolor: green,
border: 0,
- borderRadius: "50%",
- boxShadow: "0 4px 12px rgba(0, 0, 0, 0.32)",
+ borderRadius: `${spaceNewPostButtonRadius}px`,
color: "#FFFFFF",
cursor: disabled ? "default" : "pointer",
display: "flex",
flexShrink: 0,
- height: 64,
+ height: spaceNewPostButtonSize,
justifyContent: "center",
opacity: disabled ? 0.6 : 1,
p: 0,
- width: 64,
+ width: spaceNewPostButtonSize,
"&:hover:not(:disabled)": { bgcolor: "#07B422" },
"&:focus-visible": {
outline: `2px solid ${green}`,
@@ -45,7 +46,7 @@ export const SpaceNewPostButton: React.FC<{
},
}}
>
- <HugeiconsIcon icon={Add01Icon} size={32} strokeWidth={2} />
+ <HugeiconsIcon icon={Add01Icon} size={28} strokeWidth={2} />
</Box>
);
};
diff --git a/web/apps/space/src/components/OwnPostTile.tsx b/web/apps/space/src/components/OwnPostTile.tsx
new file mode 100644
index 0000000000..377ea15ced
--- /dev/null
+++ b/web/apps/space/src/components/OwnPostTile.tsx
@@ -0,0 +1,325 @@
+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"
+ ? green
+ : 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 isEmpty = !post && !loading && !unavailable;
+ const caption = post?.caption?.trim();
+
+ 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`,
+ }}
+ >
+ <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}
+ />
+ ) : (
+ <Box
+ component="span"
+ sx={{
+ color: spaceTextMuted,
+ display: "block",
+ fontSize: 12,
+ fontWeight: 400,
+ lineHeight: "18px",
+ whiteSpace: "nowrap",
+ }}
+ >
+ {loading
+ ? "Loading…"
+ : unavailable
+ ? "Post unavailable"
+ : "Share your first post."}
+ </Box>
+ )}
+ <Box
+ component="span"
+ title={post ? caption : undefined}
+ sx={{
+ color: isEmpty ? spaceText : spaceTextMuted,
+ display: "block",
+ fontSize: 12,
+ fontWeight: 400,
+ lineHeight: "20px",
+ opacity: isEmpty ? 1 : 0.65,
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ }}
+ >
+ {isEmpty
+ ? "What are you up to?"
+ : caption || "No caption"}
+ </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.tsx
index b830820c29..39e5ccbb1d 100644
--- a/web/apps/space/src/components/PostFloatingActionButton.tsx
+++ b/web/apps/space/src/components/PostFloatingActionButton.tsx
@@ -1,12 +1,15 @@
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 buttonSize = 64;
-const iconSize = 34;
+const iconSize = 28;
interface SpacePostFloatingActionButtonProps {
disabled?: boolean;
@@ -28,14 +31,14 @@ export const SpacePostFloatingActionButton: React.FC<
appearance: "none",
bgcolor: green,
border: 0,
- borderRadius: "50%",
+ borderRadius: `${spaceNewPostButtonRadius}px`,
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: buttonSize,
+ height: spaceNewPostButtonSize,
justifyContent: "center",
lineHeight: 0,
opacity: disabled ? 0.72 : 1,
@@ -44,7 +47,7 @@ export const SpacePostFloatingActionButton: React.FC<
right: "16px",
transition:
"background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease",
- width: buttonSize,
+ width: spaceNewPostButtonSize,
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.ts
new file mode 100644
index 0000000000..b66d4b37c7
--- /dev/null
+++ b/web/apps/space/src/hooks/use-own-latest-post.ts
@@ -0,0 +1,58 @@
+import log from "ente-base/log";
+import { useEffect, useState } from "react";
+import { loadCachedOwnLatestPost } from "services/post-cache";
+import {
+ loadCurrentSpaceProfilePostsPage,
+ type SpacePost,
+} from "services/space";
+import { useSpaceAppState } from "state/app-state";
+
+export const useOwnLatestPost = (spaceId: string | undefined) => {
+ const { postPublication } = useSpaceAppState();
+ const isPublishingPost = postPublication?.phase == "posting";
+ const [ownLatestPost, setOwnLatestPost] = useState<SpacePost>();
+ const [isOwnLatestPostLoading, setIsOwnLatestPostLoading] = useState(true);
+ const [isOwnLatestPostUnavailable, setIsOwnLatestPostUnavailable] =
+ useState(false);
+
+ useEffect(() => {
+ setOwnLatestPost(undefined);
+ setIsOwnLatestPostLoading(true);
+ setIsOwnLatestPostUnavailable(false);
+ if (!spaceId || isPublishingPost) return;
+
+ let cancelled = false;
+ let cachedPost: SpacePost | undefined;
+ void loadCachedOwnLatestPost(spaceId)
+ .then((post) => {
+ if (cancelled) return;
+ cachedPost = post;
+ if (post) {
+ setOwnLatestPost(post);
+ setIsOwnLatestPostLoading(false);
+ }
+ return loadCurrentSpaceProfilePostsPage(spaceId, spaceId);
+ })
+ .then((page) => {
+ if (!cancelled && page) 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;
+ };
+ }, [spaceId, 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.tsx
index 1bc002ab9e..e60f6343c3 100644
--- a/web/apps/space/src/pages/app/index.tsx
+++ b/web/apps/space/src/pages/app/index.tsx
@@ -4,6 +4,7 @@ import { SpaceFriendRequestCanceledToast } from "components/FriendRequestCancele
import { 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 {
@@ -61,6 +62,11 @@ const Page: React.FC = () => {
);
const [latestPosts, setLatestPosts] = useState<SpacePost[]>([]);
const [spaceId, setSpaceId] = useState<string>();
+ const {
+ ownLatestPost,
+ isOwnLatestPostLoading,
+ isOwnLatestPostUnavailable,
+ } = useOwnLatestPost(spaceId);
const [unreadPosts, setUnreadPosts] = useState<SpacePost[]>([]);
const [hasUnreadMessages, setHasUnreadMessages] = useState<boolean>();
const [isLatestPostsLoading, setIsLatestPostsLoading] = useState(true);
@@ -250,6 +256,9 @@ const Page: React.FC = () => {
<>
<SpacePageMeta themeColor={spaceAppBackgroundColor} />
<HomeScreen
+ ownLatestPost={ownLatestPost}
+ isOwnLatestPostLoading={isOwnLatestPostLoading}
+ isOwnLatestPostUnavailable={isOwnLatestPostUnavailable}
latestPosts={latestPosts}
unreadPosts={unreadPosts}
friendRequestSentToastName={friendRequestSentToastName}
@@ -414,6 +423,13 @@ 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.tsx
index 61a2af451f..4b12a266bd 100644
--- a/web/apps/space/src/pages/layout-demo.tsx
+++ b/web/apps/space/src/pages/layout-demo.tsx
@@ -5,7 +5,7 @@ import { SpaceAddFriendDialog } from "components/AddFriendDialog";
import { SpaceAddFriendTile } from "components/AddFriendTile";
import { SpaceFileViewer } from "components/FileViewer";
import { SpaceHomeHeader, spaceHomeHeaderHeight } from "components/HomeHeader";
-import { SpaceNewPostButton } from "components/NewPostButton";
+import { SpaceOwnPostTile } from "components/OwnPostTile";
import { useBrowserBackClose } from "hooks/use-browser-back-close";
import React from "react";
import { FriendPostTile } from "screens/HomeScreen";
@@ -30,6 +30,15 @@ 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",
@@ -178,10 +187,14 @@ const LayoutDemoPage: React.FC = () => {
Math.max(0, Math.min(maximumHomeTileCount, count + delta)),
);
}, []);
- const [isPostPreviewOpen, setIsPostPreviewOpen] = React.useState(false);
+ const [ownPost, setOwnPost] = React.useState<SpacePost>();
+ const [postPreviewActionMode, setPostPreviewActionMode] = React.useState<
+ "draft-post" | "hidden"
+ >();
+ const isPostPreviewOpen = postPreviewActionMode !== undefined;
useBrowserBackClose({
open: isPostPreviewOpen,
- onClose: () => setIsPostPreviewOpen(false),
+ onClose: () => setPostPreviewActionMode(undefined),
stateKey: "space-layout-demo-viewer",
});
const [canvasSize, setCanvasSize] = React.useState<CanvasSize>({
@@ -378,8 +391,10 @@ const LayoutDemoPage: React.FC = () => {
</>
)}
</Box>
- <SpaceNewPostButton
- onClick={() => setIsPostPreviewOpen(true)}
+ <SpaceOwnPostTile
+ post={ownPost}
+ onNewPost={() => setPostPreviewActionMode("draft-post")}
+ onOpenPost={() => setPostPreviewActionMode("hidden")}
/>
</Box>
<SpaceAddFriendDialog
@@ -397,15 +412,21 @@ const LayoutDemoPage: React.FC = () => {
{isPostPreviewOpen && (
<SpaceFileViewer
photo={{
+ ...(ownPost ?? demoOwnPost),
alt: "Your post",
avatarUrl: demoProfile.avatarUrl,
imageUrl: spaceDefaultCoverImagePath,
- name: demoProfile.fullName,
- timestampMs: 1_700_000_000_000,
}}
- postActionMode="draft-post"
- onClose={() => setIsPostPreviewOpen(false)}
- onPublishDraftPost={() => Promise.resolve()}
+ postActionMode={postPreviewActionMode}
+ onClose={() => setPostPreviewActionMode(undefined)}
+ onPublishDraftPost={(caption) => {
+ setOwnPost({
+ ...demoOwnPost,
+ caption,
+ timestampMs: Date.now(),
+ });
+ return Promise.resolve();
+ }}
/>
)}
</Box>
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 5e12adfb38..ad5a9ed245 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -17,7 +17,7 @@ import {
import { FriendQuickActionsDialog } from "components/FriendQuickActionsDialog";
import { FriendTilePokeButton } from "components/FriendTilePokeButton";
import { SpaceHomeHeader, spaceHomeHeaderHeight } from "components/HomeHeader";
-import { SpaceNewPostButton } from "components/NewPostButton";
+import { SpaceOwnPostTile } from "components/OwnPostTile";
import {
SpacePostBadge,
SpacePostUnreadBadge,
@@ -79,6 +79,9 @@ 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;
@@ -109,6 +112,7 @@ interface HomeScreenProps {
onOpenMessages?: () => void;
onMessageFriend: (friend: FriendProfile) => void;
onPokeFriend: (friend: FriendProfile) => Promise<void>;
+ onOpenOwnPost?: () => void;
onOpenProfile?: () => void;
onReplyToPost?: (
postSpaceId: string,
@@ -999,6 +1003,9 @@ const AddedFriendToast: React.FC<AddedFriendToastProps> = ({
);
export const HomeScreen: React.FC<HomeScreenProps> = ({
+ ownLatestPost,
+ isOwnLatestPostLoading = false,
+ isOwnLatestPostUnavailable = false,
latestPosts,
unreadPosts,
friendRequestSentToastName,
@@ -1022,6 +1029,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
onOpenMessages,
onMessageFriend,
onPokeFriend,
+ onOpenOwnPost,
onOpenProfile,
onReplyToPost,
onSetPostLiked,
@@ -1749,9 +1757,14 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
)
)}
</Box>
- <SpaceNewPostButton
- isDisabled={isPostPhotoButtonDisabled}
- onClick={openPostPhotoPicker}
+ <SpaceOwnPostTile
+ post={ownLatestPost}
+ isLoading={isOwnLatestPostLoading}
+ isUnavailable={isOwnLatestPostUnavailable}
+ isNewPostDisabled={isPostPhotoButtonDisabled}
+ onLoadPostImage={onLoadPostImage}
+ onNewPost={openPostPhotoPicker}
+ onOpenPost={onOpenOwnPost}
/>
</Box>
{selectedContact && (
diff --git a/web/apps/space/src/state/AppStateProvider.tsx b/web/apps/space/src/state/AppStateProvider.tsx
index 20e3b3eed9..fdffc096e6 100644
--- a/web/apps/space/src/state/AppStateProvider.tsx
+++ b/web/apps/space/src/state/AppStateProvider.tsx
@@ -36,6 +36,8 @@ import {
} from "state/app-state";
import { prepareSpacePostImageFromEdit } from "utils/post-image";
+const postStatusDurationMs = 2000;
+
export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({
children,
}) => {
@@ -150,6 +152,7 @@ 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.tsx
index 9aa7dd61f3..f01b80bfc9 100644
--- a/web/apps/space/src/state/app-state.tsx
+++ b/web/apps/space/src/state/app-state.tsx
@@ -17,6 +17,7 @@ export interface SpacePostPublication {
phase: SpacePostPublishPhase;
post: SpacePost;
previewUrl: string;
+ statusExpiresAtMs?: number;
}
export type PendingCreateProfile = SetupProfileDetails & {
source: CreateProfileSource;