Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add first-post invite toast

Anand Baburajan1c4037d21125
diff --git a/web/apps/space/src/components/SpaceActionToast.tsx b/web/apps/space/src/components/SpaceActionToast.tsx
new file mode 100644
index 0000000000..08dd89f1a5
--- /dev/null
+++ b/web/apps/space/src/components/SpaceActionToast.tsx
@@ -0,0 +1,154 @@
+import { MultiplicationSignIcon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { Box } from "@mui/material";
+import { keyframes } from "@mui/material/styles";
+import React from "react";
+import { spaceTouchTargetSize } from "styles/touchTargets";
+
+const green = "#08C225";
+const textBase = "#000";
+const toastHorizontalPadding = "16px";
+const toastEnter = keyframes`
+ from {
+ opacity: 0;
+ transform: translateX(-50%) translateY(-10px);
+ }
+
+ to {
+ opacity: 1;
+ transform: translateX(-50%) translateY(0);
+ }
+`;
+
+interface SpaceActionToastProps {
+ action?: React.ReactNode;
+ animateEntrance?: boolean;
+ closeLabel: string;
+ icon: React.ReactNode;
+ message: React.ReactNode;
+ onClose?: () => void;
+ zIndex?: number;
+}
+
+export const SpaceActionToast: React.FC<SpaceActionToastProps> = ({
+ action,
+ animateEntrance = false,
+ closeLabel,
+ icon,
+ message,
+ onClose,
+ zIndex = 20,
+}) => (
+ <Box
+ sx={{
+ animation: animateEntrance
+ ? `${toastEnter} 320ms cubic-bezier(0.22, 1, 0.36, 1) both`
+ : undefined,
+ boxSizing: "border-box",
+ left: "50%",
+ px: toastHorizontalPadding,
+ pointerEvents: "none",
+ position: "fixed",
+ top: "calc(env(safe-area-inset-top) + 10px)",
+ transform: "translateX(-50%)",
+ width: "100%",
+ zIndex,
+ "@media (min-width: 600px)": { maxWidth: 390 },
+ "@media (prefers-reduced-motion: reduce)": {
+ animation: animateEntrance ? "none" : undefined,
+ },
+ }}
+ >
+ <Box
+ role="status"
+ aria-live="polite"
+ sx={{
+ alignItems: "center",
+ bgcolor: "#FFFFFF",
+ borderRadius: "18px",
+ boxShadow: "0 12px 32px rgba(0, 0, 0, 0.18)",
+ boxSizing: "border-box",
+ color: textBase,
+ display: "flex",
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 14,
+ fontWeight: 650,
+ gap: "10px",
+ lineHeight: "20px",
+ minHeight: 50,
+ pointerEvents: "auto",
+ pl: "10px",
+ pr: "6px",
+ py: "3px",
+ width: "100%",
+ }}
+ >
+ <Box
+ component="span"
+ sx={{
+ alignItems: "center",
+ color: green,
+ display: "flex",
+ flexShrink: 0,
+ height: 24,
+ justifyContent: "center",
+ width: 24,
+ }}
+ >
+ {icon}
+ </Box>
+ <Box
+ sx={{
+ flex: "1 1 auto",
+ minWidth: 0,
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ }}
+ >
+ {message}
+ </Box>
+ <Box
+ sx={{
+ alignItems: "center",
+ display: "flex",
+ flexShrink: 0,
+ gap: 0,
+ }}
+ >
+ {action}
+ <Box
+ component="button"
+ type="button"
+ aria-label={closeLabel}
+ onClick={onClose}
+ sx={{
+ alignItems: "center",
+ appearance: "none",
+ bgcolor: "transparent",
+ border: 0,
+ color: textBase,
+ cursor: onClose ? "pointer" : "default",
+ display: "flex",
+ flexShrink: 0,
+ height: spaceTouchTargetSize,
+ justifyContent: "center",
+ opacity: 0.9,
+ p: 0,
+ width: 36,
+ "&:focus-visible": {
+ outline: "2px solid rgba(0 0 0 / 0.72)",
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <HugeiconsIcon
+ icon={MultiplicationSignIcon}
+ size={16}
+ strokeWidth={2}
+ />
+ </Box>
+ </Box>
+ </Box>
+ </Box>
+);
diff --git a/web/apps/space/src/components/SpaceFileViewer.tsx b/web/apps/space/src/components/SpaceFileViewer.tsx
index 3365c7c9b4..192b90847d 100644
--- a/web/apps/space/src/components/SpaceFileViewer.tsx
+++ b/web/apps/space/src/components/SpaceFileViewer.tsx
@@ -57,6 +57,7 @@ const viewerSwipeMinDeltaPx = 72;
const viewerSwipeAxisRatio = 1.5;
const viewerHeaderAvatarSize = 28;
const viewerHeaderButtonVisualSize = 28;
+const draftPostExitDurationMs = 320;
interface ViewerViewportSize {
x: number;
@@ -150,6 +151,7 @@ interface SpaceFileViewerProps {
isDraftPostPreviewPending?: boolean;
onClose: () => void;
onDeletePost?: () => Promise<void> | void;
+ onDraftPostExitStart?: () => void;
onDraftPostPublished?: () => void;
onOpenProfile?: () => void;
onPublishDraftPost?: (
@@ -233,18 +235,23 @@ const viewerActionButtonSx = {
"&:hover": { bgcolor: controlBackgroundHover },
};
-export const SpaceViewerFeedBackdrop: React.FC = () => (
+export const SpaceViewerFeedBackdrop: React.FC<{ exiting?: boolean }> = ({
+ exiting = false,
+}) => (
<Box
aria-hidden
sx={{
bgcolor: viewerBackground,
bottom: "-100vh",
left: 0,
+ opacity: exiting ? 0 : 1,
pointerEvents: "none",
position: "absolute",
right: 0,
top: "-100vh",
+ transition: `opacity ${draftPostExitDurationMs}ms cubic-bezier(0.22, 1, 0.36, 1)`,
zIndex: 1299,
+ "@media (prefers-reduced-motion: reduce)": { transition: "none" },
}}
/>
);
@@ -298,6 +305,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
isDraftPostPreviewPending = false,
onClose,
onDeletePost,
+ onDraftPostExitStart,
onDraftPostPublished,
onOpenProfile,
onPublishDraftPost,
@@ -381,6 +389,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
React.useState<SpaceActionPhase | null>(null);
const [draftPostActionPhase, setDraftPostActionPhase] =
React.useState<SpaceActionPhase | null>(null);
+ const [isDraftPostExit, setIsDraftPostExit] = React.useState(false);
const [isDesktopViewer, setIsDesktopViewer] = React.useState(
() =>
typeof window != "undefined" &&
@@ -448,6 +457,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
isActionsOpen ||
(canDeletePost && deleteSheetOpen) ||
isDeleteExit ||
+ isDraftPostExit ||
isCaptionEditing ||
isDraftPost ||
isDraftPostPreviewPending;
@@ -578,7 +588,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
const publishDraftPostWithCaption = React.useCallback(
(captionToPublish: string, editToPublish: SpaceViewerDraftPostEdit) => {
- if (!onPublishDraftPost || isDeleteExit) return;
+ if (!onPublishDraftPost || isDeleteExit || isDraftPostExit) return;
setDraftPostActionPhase("busy");
let publishPromise: Promise<void>;
@@ -593,13 +603,18 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
}
setQueuedDraftPost(undefined);
- onClose();
- onDraftPostPublished?.();
+ setIsDraftPostExit(true);
+ onDraftPostExitStart?.();
void publishPromise.catch((error: unknown) => {
console.error("Failed to publish space post", error);
});
},
- [isDeleteExit, onClose, onDraftPostPublished, onPublishDraftPost],
+ [
+ isDeleteExit,
+ isDraftPostExit,
+ onDraftPostExitStart,
+ onPublishDraftPost,
+ ],
);
const publishDraftPost = () => {
@@ -608,7 +623,8 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
isDraftPostActionRunning ||
isDraftPostPreviewPending ||
hasDraftPostPreparationError ||
- isDeleteExit
+ isDeleteExit ||
+ isDraftPostExit
)
return;
@@ -811,6 +827,17 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
onClose();
}, [isDeleteExit, onClose]);
+ const finishDraftPostExit = React.useCallback(() => {
+ onClose();
+ onDraftPostPublished?.();
+ }, [onClose, onDraftPostPublished]);
+
+ React.useEffect(() => {
+ if (!isDraftPostExit) return;
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches)
+ finishDraftPostExit();
+ }, [finishDraftPostExit, isDraftPostExit]);
+
React.useEffect(() => {
const root = viewerRootRef.current;
if (!root || !canReplyToPost) return;
@@ -1025,7 +1052,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
React.useEffect(() => {
const closeOnEscape = (event: KeyboardEvent) => {
- if (deleteSheetOpen) return;
+ if (deleteSheetOpen || isDraftPostExit) return;
if (event.key != "Escape") return;
if (isCaptionEditing && !isCaptionUpdateActionRunning) {
@@ -1040,6 +1067,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
}, [
cancelCaptionEdit,
deleteSheetOpen,
+ isDraftPostExit,
isCaptionEditing,
isCaptionUpdateActionRunning,
]);
@@ -1050,6 +1078,16 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
role="dialog"
aria-label={`${displayName} photo viewer`}
aria-modal="true"
+ onTransitionEnd={(event) => {
+ if (
+ !isDraftPostExit ||
+ event.currentTarget != event.target ||
+ event.propertyName != "opacity"
+ )
+ return;
+
+ finishDraftPostExit();
+ }}
sx={{
bgcolor: viewerBackground,
boxSizing: "border-box",
@@ -1060,11 +1098,17 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
isolation: "isolate",
maxWidth: "100vw",
minHeight: "100svh",
+ opacity: isDraftPostExit ? 0 : 1,
overflow: "hidden",
overflowX: "hidden",
+ pointerEvents: isDraftPostExit ? "none" : "auto",
position: "fixed",
+ transition: `opacity ${draftPostExitDurationMs}ms cubic-bezier(0.22, 1, 0.36, 1)`,
width: "100%",
zIndex: 1300,
+ "@media (prefers-reduced-motion: reduce)": {
+ transition: "none",
+ },
}}
>
<Box
diff --git a/web/apps/space/src/components/SpacePWAInstallPrompt.tsx b/web/apps/space/src/components/SpacePWAInstallPrompt.tsx
index 8118cc8e3e..9bda26c73f 100644
--- a/web/apps/space/src/components/SpacePWAInstallPrompt.tsx
+++ b/web/apps/space/src/components/SpacePWAInstallPrompt.tsx
@@ -3,21 +3,19 @@ import {
ArrowDown01Icon,
MoreHorizontalIcon,
MoreVerticalIcon,
- MultiplicationSignIcon,
ScreenAddToHomeIcon,
Upload01Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Dialog, useMediaQuery } from "@mui/material";
+import { SpaceActionToast } from "components/SpaceActionToast";
import { SpaceBottomSheetTransition } from "components/SpaceBottomSheetTransition";
import { useSpacePWAInstallPrompt } from "hooks/useSpacePWAInstallPrompt";
import React from "react";
-import { spaceTouchTargetSize } from "styles/touchTargets";
const green = "#08C225";
const textBase = "#000";
const textSoft = "#777777";
-const promptHorizontalPadding = "16px";
interface SpacePWAInstallPromptProps {
enabled: boolean;
@@ -50,148 +48,53 @@ export const SpacePWAInstallPrompt: React.FC<SpacePWAInstallPromptProps> = ({
return (
<>
- <Box
- sx={{
- boxSizing: "border-box",
- left: "50%",
- px: promptHorizontalPadding,
- pointerEvents: "none",
- position: "fixed",
- top: "calc(env(safe-area-inset-top) + 10px)",
- transform: "translateX(-50%)",
- width: "100%",
- zIndex: 19,
- "@media (min-width: 600px)": { maxWidth: 390 },
- }}
- >
- <Box
- role="status"
- aria-live="polite"
- sx={{
- alignItems: "center",
- bgcolor: "#FFFFFF",
- borderRadius: "18px",
- boxShadow: "0 12px 32px rgba(0, 0, 0, 0.18)",
- boxSizing: "border-box",
- color: textBase,
- display: "flex",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 650,
- gap: "10px",
- lineHeight: "20px",
- minHeight: 50,
- pointerEvents: "auto",
- pl: "10px",
- pr: "6px",
- py: "3px",
- width: "100%",
- }}
- >
+ <SpaceActionToast
+ action={
<Box
- component="span"
+ component="button"
+ type="button"
+ onClick={openInstructions}
sx={{
alignItems: "center",
- color: green,
+ bgcolor: green,
+ border: 0,
+ borderRadius: "14px",
+ color: "#FFFFFF",
+ cursor: "pointer",
display: "flex",
flexShrink: 0,
- height: 24,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 13,
+ fontWeight: 700,
+ height: 34,
justifyContent: "center",
- width: 24,
+ lineHeight: "18px",
+ minWidth: 48,
+ px: "17px",
+ transition: "filter 120ms ease",
+ "&:active": { filter: "brightness(0.96)" },
+ "&:focus-visible": {
+ outline: "2px solid rgba(0 0 0 / 0.72)",
+ outlineOffset: 2,
+ },
+ "&:hover": { filter: "brightness(0.98)" },
}}
>
- <HugeiconsIcon
- icon={ScreenAddToHomeIcon}
- size={24}
- strokeWidth={1.9}
- />
+ Add
</Box>
- <Box
- sx={{
- flex: "1 1 auto",
- minWidth: 0,
- overflow: "hidden",
- textOverflow: "ellipsis",
- whiteSpace: "nowrap",
- }}
- >
- Add to home screen
- </Box>
- <Box
- sx={{
- alignItems: "center",
- display: "flex",
- flexShrink: 0,
- gap: 0,
- }}
- >
- <Box
- component="button"
- type="button"
- onClick={openInstructions}
- sx={{
- alignItems: "center",
- bgcolor: green,
- border: 0,
- borderRadius: "14px",
- color: "#FFFFFF",
- cursor: "pointer",
- display: "flex",
- flexShrink: 0,
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 13,
- fontWeight: 700,
- height: 34,
- justifyContent: "center",
- lineHeight: "18px",
- minWidth: 48,
- px: "17px",
- transition: "filter 120ms ease",
- "&:active": { filter: "brightness(0.96)" },
- "&:focus-visible": {
- outline: "2px solid rgba(0 0 0 / 0.72)",
- outlineOffset: 2,
- },
- "&:hover": { filter: "brightness(0.98)" },
- }}
- >
- Add
- </Box>
- <Box
- component="button"
- type="button"
- aria-label="Close install prompt"
- onClick={dismiss}
- sx={{
- alignItems: "center",
- appearance: "none",
- bgcolor: "transparent",
- border: 0,
- color: textBase,
- cursor: "pointer",
- display: "flex",
- flexShrink: 0,
- height: spaceTouchTargetSize,
- justifyContent: "center",
- opacity: 0.9,
- p: 0,
- width: 36,
- "&:focus-visible": {
- outline: "2px solid rgba(0 0 0 / 0.72)",
- outlineOffset: 2,
- },
- }}
- >
- <HugeiconsIcon
- icon={MultiplicationSignIcon}
- size={16}
- strokeWidth={2}
- />
- </Box>
- </Box>
- </Box>
- </Box>
+ }
+ closeLabel="Close install prompt"
+ icon={
+ <HugeiconsIcon
+ icon={ScreenAddToHomeIcon}
+ size={24}
+ strokeWidth={1.9}
+ />
+ }
+ message="Add to home screen"
+ onClose={dismiss}
+ zIndex={19}
+ />
<SpacePWAInstallInstructions
mode={mode}
open={instructionsOpen}
diff --git a/web/apps/space/src/components/SpaceShareInviteButton.tsx b/web/apps/space/src/components/SpaceShareInviteButton.tsx
index 107aaaf06a..2d598b0131 100644
--- a/web/apps/space/src/components/SpaceShareInviteButton.tsx
+++ b/web/apps/space/src/components/SpaceShareInviteButton.tsx
@@ -34,7 +34,9 @@ export const SpaceShareIcon: React.FC<{ strokeWidth?: number }> = ({
interface SpaceShareInviteButtonProps {
className?: string;
iconStrokeWidth?: number;
+ label?: string;
profileLink?: string;
+ showIcon?: boolean;
sharing?: boolean;
sx?: SxProps<Theme>;
onShareComplete?: () => void;
@@ -46,7 +48,9 @@ interface SpaceShareInviteButtonProps {
export const SpaceShareInviteButton: React.FC<SpaceShareInviteButtonProps> = ({
className,
iconStrokeWidth,
+ label,
profileLink,
+ showIcon = true,
sharing,
sx,
onShareComplete,
@@ -60,11 +64,12 @@ export const SpaceShareInviteButton: React.FC<SpaceShareInviteButtonProps> = ({
const isSharing = sharing ?? phase == "sharing";
const isDisabled = isSharing || !profileLink;
const buttonLabel =
- phase == "copied"
+ label ??
+ (phase == "copied"
? "Invite link copied"
: isSharing
? "Sharing invite..."
- : "Share invite";
+ : "Share invite");
const setSharing = (nextSharing: boolean) => {
if (sharing === undefined) setPhase(nextSharing ? "sharing" : "idle");
@@ -125,7 +130,7 @@ export const SpaceShareInviteButton: React.FC<SpaceShareInviteButtonProps> = ({
onClick={() => void shareInvite()}
sx={sx}
>
- <SpaceShareIcon strokeWidth={iconStrokeWidth} />
+ {showIcon && <SpaceShareIcon strokeWidth={iconStrokeWidth} />}
{buttonLabel}
</Box>
);
diff --git a/web/apps/space/src/pages/app/index.tsx b/web/apps/space/src/pages/app/index.tsx
index ef50ef9535..bc3c029260 100644
--- a/web/apps/space/src/pages/app/index.tsx
+++ b/web/apps/space/src/pages/app/index.tsx
@@ -30,6 +30,8 @@ import { prepareSpacePostImageFromEdit } from "utils/spacePostImage";
import { spaceRoutes } from "utils/spaceRoutes";
import { useSpaceRouter } from "utils/spaceRouteTransitions";
+const inviteFriendsToastDelayMs = 3000;
+
const Page: React.FC = () => {
const router = useSpaceRouter();
const {
@@ -52,6 +54,10 @@ const Page: React.FC = () => {
const [isFeedLoading, setIsFeedLoading] = useState(true);
const [isFeedLoadingMore, setIsFeedLoadingMore] = useState(false);
const [isFriendsLoading, setIsFriendsLoading] = useState(true);
+ const [showInviteFriendsToast, setShowInviteFriendsToast] = useState(false);
+ const inviteFriendsToastTimerRef = React.useRef<number | undefined>(
+ undefined,
+ );
const isInitialFeedLoading =
profileLoadStatus == "ready" &&
Boolean(profile?.spaceId) &&
@@ -65,6 +71,18 @@ const Page: React.FC = () => {
() => setFriendRequestSentToastName(undefined),
[],
);
+ const closeInviteFriendsToast = React.useCallback(
+ () => setShowInviteFriendsToast(false),
+ [],
+ );
+
+ useEffect(
+ () => () => {
+ if (inviteFriendsToastTimerRef.current !== undefined)
+ window.clearTimeout(inviteFriendsToastTimerRef.current);
+ },
+ [],
+ );
useEffect(() => {
if (profileLoadStatus == "ready" && !profile) {
@@ -230,13 +248,26 @@ const Page: React.FC = () => {
Boolean(profile) &&
!isHomeFeedLoading
}
+ showInviteFriendsToast={
+ showInviteFriendsToast &&
+ !isFriendsLoading &&
+ friends.length == 0
+ }
onFriendRequestSentToastClose={closeFriendRequestSentToast}
+ onInviteFriendsToastClose={closeInviteFriendsToast}
onCreatePost={
profile
? async (image, caption) => {
const spaceId = profile.spaceId;
if (!spaceId) throw new Error("Missing space.");
+ const isFirstPost =
+ !feedItems.some(
+ (item) => item.spaceId == spaceId,
+ ) &&
+ !localFeedPosts.some(
+ (item) => item.status != "failed",
+ );
const localPostId = createLocalFeedPostID();
const displayName =
profile.fullName.trim() ||
@@ -281,6 +312,14 @@ const Page: React.FC = () => {
localPostId,
post,
);
+ if (isFirstPost) {
+ inviteFriendsToastTimerRef.current =
+ window.setTimeout(() => {
+ setShowInviteFriendsToast(true);
+ inviteFriendsToastTimerRef.current =
+ undefined;
+ }, inviteFriendsToastDelayMs);
+ }
} catch (error) {
failLocalFeedPost(
setLocalFeedPosts,
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index d3c739fdea..3dc5216b84 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -6,6 +6,7 @@ import {
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Skeleton } from "@mui/material";
+import { SpaceActionToast } from "components/SpaceActionToast";
import { SpaceAvatarImage } from "components/SpaceAvatarImage";
import {
SpaceFileViewer,
@@ -115,6 +116,7 @@ interface HomeScreenProps {
isFriendsLoading?: boolean;
localFeedPosts?: LocalSpaceFeedPost[];
showInstallPrompt?: boolean;
+ showInviteFriendsToast?: boolean;
onCreatePost?: (
image: DraftSpacePostImage,
caption: string,
@@ -124,6 +126,7 @@ interface HomeScreenProps {
onLoadPostAvatar?: SpacePostAvatarURLLoader;
onLoadPostImage?: SpacePostAssetURLLoader;
onFriendRequestSentToastClose?: () => void;
+ onInviteFriendsToastClose?: () => void;
onOpenFriend?: (friendID: string) => void;
onOpenMessages?: () => void;
onOpenProfile?: () => void;
@@ -203,6 +206,13 @@ interface AddedFriendToastProps {
onClose?: () => void;
}
+interface InviteFriendsToastProps {
+ profileLink?: string;
+ sharing: boolean;
+ onClose?: () => void;
+ onSharingChange: (sharing: boolean) => void;
+}
+
const dimensionsFromAspectRatio = (
aspectRatio: number,
): FeedPhotoDimensions => {
@@ -1209,6 +1219,68 @@ const AddedFriendToast: React.FC<AddedFriendToastProps> = ({
</Box>
);
+const InviteFriendsToast: React.FC<InviteFriendsToastProps> = ({
+ profileLink,
+ sharing,
+ onClose,
+ onSharingChange,
+}) => (
+ <SpaceActionToast
+ action={
+ <SpaceShareInviteButton
+ label="Invite"
+ profileLink={profileLink}
+ sharing={sharing}
+ showIcon={false}
+ onShareComplete={onClose}
+ onShareError={(error) =>
+ console.error("Failed to share space invite", error)
+ }
+ onSharingChange={onSharingChange}
+ sx={{
+ alignItems: "center",
+ bgcolor: green,
+ border: 0,
+ borderRadius: "14px",
+ color: "#FFFFFF",
+ cursor: profileLink && !sharing ? "pointer" : "default",
+ display: "flex",
+ flexShrink: 0,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 13,
+ fontWeight: 700,
+ height: 34,
+ justifyContent: "center",
+ lineHeight: "18px",
+ minWidth: 48,
+ px: "17px",
+ transition: "filter 120ms ease",
+ "&:active":
+ profileLink && !sharing
+ ? { filter: "brightness(0.96)" }
+ : undefined,
+ "&:disabled": { opacity: 0.45 },
+ "&:focus-visible": {
+ outline: "2px solid rgba(0 0 0 / 0.72)",
+ outlineOffset: 2,
+ },
+ "&:hover":
+ profileLink && !sharing
+ ? { filter: "brightness(0.98)" }
+ : undefined,
+ }}
+ />
+ }
+ animateEntrance
+ closeLabel="Close invite prompt"
+ icon={
+ <HugeiconsIcon icon={UserAdd02Icon} size={24} strokeWidth={1.9} />
+ }
+ message="Invite friends to your Space"
+ onClose={onClose}
+ />
+);
+
export const HomeScreen: React.FC<HomeScreenProps> = ({
feedItems,
friendRequestSentToastName,
@@ -1221,12 +1293,14 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
isFriendsLoading = false,
localFeedPosts = [],
showInstallPrompt = false,
+ showInviteFriendsToast = false,
onCreatePost,
onDeletePost,
onLoadMoreFeedItems,
onLoadPostAvatar,
onLoadPostImage,
onFriendRequestSentToastClose,
+ onInviteFriendsToastClose,
onOpenFriend,
onOpenMessages,
onOpenProfile,
@@ -1238,6 +1312,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
}) => {
const [selectedViewer, setSelectedViewer] =
useState<SelectedHomeViewer | null>(null);
+ const [isDraftPostExiting, setIsDraftPostExiting] = useState(false);
const [isInviteSharing, setIsInviteSharing] = useState(false);
const [isPostPhotoOpening, setIsPostPhotoOpening] = useState(false);
const [loadedFeedAvatarURLsByKey, setLoadedFeedAvatarURLsByKey] = useState<
@@ -1279,7 +1354,10 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
const isEmptyFeedLoading = !hasFeedItems && isFeedLoading;
const showFeedCards = hasFeedItems;
const isInstallPromptEnabled =
- showInstallPrompt && !friendRequestSentToastName && !selectedViewer;
+ showInstallPrompt &&
+ !friendRequestSentToastName &&
+ !showInviteFriendsToast &&
+ !selectedViewer;
const showUnreadIndicator = hasUnreadMessages === true;
const hasLoadedNoFriends = !isFriendsLoading && friendsCount == 0;
const emptyFeedMessage = hasLoadedNoFriends
@@ -1316,6 +1394,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
};
const closeSelectedPhoto = () => {
activeLocalPostObjectUrlRef.current = null;
+ setIsDraftPostExiting(false);
setSelectedViewer(null);
revokeLocalPostObjectUrls();
};
@@ -1672,7 +1751,9 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
position: "relative",
}}
>
- {selectedViewer && <SpaceViewerFeedBackdrop />}
+ {selectedViewer && (
+ <SpaceViewerFeedBackdrop exiting={isDraftPostExiting} />
+ )}
<Box
sx={{
bgcolor: homeBackground,
@@ -2153,9 +2234,10 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
}
: undefined
}
- onDraftPostPublished={() =>
- setFeedScrollRequest((request) => request + 1)
- }
+ onDraftPostExitStart={() => {
+ setIsDraftPostExiting(true);
+ setFeedScrollRequest((request) => request + 1);
+ }}
onSetPostLiked={onSetPostLiked}
onUpdatePostCaption={
selectedPhotoIsOwn ? onUpdatePostCaption : undefined
@@ -2167,6 +2249,13 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
message={`Friend request sent to @${friendRequestSentToastName}`}
onClose={onFriendRequestSentToastClose}
/>
+ ) : showInviteFriendsToast ? (
+ <InviteFriendsToast
+ profileLink={profileLink}
+ sharing={isInviteSharing}
+ onClose={onInviteFriendsToastClose}
+ onSharingChange={setIsInviteSharing}
+ />
) : (
<SpacePWAInstallPrompt enabled={isInstallPromptEnabled} />
)}
diff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsx
index 45e8f50393..371fd68996 100644
--- a/web/apps/space/src/screens/ProfileScreen.tsx
+++ b/web/apps/space/src/screens/ProfileScreen.tsx
@@ -586,6 +586,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
}) => {
const [selectedPost, setSelectedPost] =
useState<SelectedProfilePost | null>(null);
+ const [isDraftPostExiting, setIsDraftPostExiting] = useState(false);
const [isPostPhotoOpening, setIsPostPhotoOpening] = useState(false);
const [deletedPostIDs, setDeletedPostIDs] = useState<Set<string>>(
() => new Set(),
@@ -778,6 +779,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
};
const closeSelectedPost = () => {
activeLocalPostObjectUrlRef.current = null;
+ setIsDraftPostExiting(false);
setSelectedPost(null);
revokeLocalPostObjectUrls();
};
@@ -1135,7 +1137,9 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
position: "relative",
}}
>
- {selectedPost && <SpaceViewerFeedBackdrop />}
+ {selectedPost && (
+ <SpaceViewerFeedBackdrop exiting={isDraftPostExiting} />
+ )}
<Box
sx={{
bgcolor: profileBackground,
@@ -2034,6 +2038,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
: handleSelectedPostIndexChange
}
onClose={closeSelectedPost}
+ onDraftPostExitStart={() => setIsDraftPostExiting(true)}
onDeletePost={
isOwnerProfile ? deleteSelectedPost : undefined
}