π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix draft post exit sequencing
Anand Baburajan5dbecef161a3
diff --git a/web/apps/space/src/components/SpaceFileViewer.tsx b/web/apps/space/src/components/SpaceFileViewer.tsxindex aad10f0082..1190946559 100644--- a/web/apps/space/src/components/SpaceFileViewer.tsx+++ b/web/apps/space/src/components/SpaceFileViewer.tsx@@ -150,6 +150,8 @@ interface SpaceViewerDeleteSnapshot {photos: SpaceViewerPhoto[];}+type DraftPostExitPhase = "idle" | "waiting-for-keyboard" | "animating";+interface SpaceFileViewerProps {draftPostPreparationError?: string;isDraftPostPreparing?: boolean;@@ -446,7 +448,10 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({React.useState<SpaceInviteIntent>("like");const [draftPostActionPhase, setDraftPostActionPhase] =React.useState<SpaceActionPhase | null>(null);- const [isDraftPostExit, setIsDraftPostExit] = React.useState(false);+ const [draftPostExitPhase, setDraftPostExitPhase] =+ React.useState<DraftPostExitPhase>("idle");+ const isDraftPostExit = draftPostExitPhase != "idle";+ const isDraftPostExitAnimating = draftPostExitPhase == "animating";const [isDesktopViewer, setIsDesktopViewer] = React.useState(() =>typeof window != "undefined" &&@@ -589,6 +594,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({}, [caption]);const closeViewer = () => {+ if (isDraftPostExit) return;if (isCaptionEditing && !isCaptionUpdateActionRunning) {cancelCaptionEdit();return;@@ -660,11 +666,6 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({};}, [activePhoto.height, activePhoto.width]);- const startDraftPostExit = React.useCallback(() => {- setIsDraftPostExit(true);- onDraftPostExitStart?.();- }, [onDraftPostExitStart]);-const dismissCaptionKeyboard = React.useCallback((onDismissed: () => void) => {const input = captionInputRef.current;@@ -738,7 +739,9 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({}setQueuedDraftPost(undefined);- dismissCaptionKeyboard(startDraftPostExit);+ setDraftPostExitPhase("waiting-for-keyboard");+ onDraftPostExitStart?.();+ dismissCaptionKeyboard(() => setDraftPostExitPhase("animating"));void publishPromise.catch((error: unknown) => {log.error("Failed to publish space post", error);});@@ -747,8 +750,8 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({isDeleteExit,isDraftPostExit,dismissCaptionKeyboard,+ onDraftPostExitStart,onPublishDraftPost,- startDraftPostExit,],);@@ -993,10 +996,10 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({}, [onClose, onDraftPostPublished]);React.useEffect(() => {- if (!isDraftPostExit) return;+ if (!isDraftPostExitAnimating) return;if (window.matchMedia("(prefers-reduced-motion: reduce)").matches)finishDraftPostExit();- }, [finishDraftPostExit, isDraftPostExit]);+ }, [finishDraftPostExit, isDraftPostExitAnimating]);React.useEffect(() => {const root = viewerRootRef.current;@@ -1242,7 +1245,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({aria-modal="true"onTransitionEnd={(event) => {if (- !isDraftPostExit ||+ !isDraftPostExitAnimating ||event.currentTarget != event.target ||event.propertyName != "opacity")@@ -1260,7 +1263,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({isolation: "isolate",maxWidth: "100vw",minHeight: "100svh",- opacity: isDraftPostExit ? 0 : 1,+ opacity: isDraftPostExitAnimating ? 0 : 1,overflow: "hidden",overflowX: "hidden",pointerEvents: isDraftPostExit ? "none" : "auto",diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsxindex c767bded94..a4aa7f82e1 100644--- a/web/apps/space/src/screens/HomeScreen.tsx+++ b/web/apps/space/src/screens/HomeScreen.tsx@@ -1626,7 +1626,9 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({const { clearBrowserBackState: clearSelectedPhotoHistory } =useBrowserBackClose({open: Boolean(selectedViewer),- onClose: closeSelectedPhoto,+ onClose: () => {+ if (!isDraftPostExiting) closeSelectedPhoto();+ },stateKey: "space-feed-viewer",});const deleteSelectedPost = async () => {diff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsxindex 123ade219f..87c1a7a85c 100644--- a/web/apps/space/src/screens/ProfileScreen.tsx+++ b/web/apps/space/src/screens/ProfileScreen.tsx@@ -676,7 +676,9 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({const { clearBrowserBackState: clearSelectedPostHistory } =useBrowserBackClose({open: Boolean(selectedPost),- onClose: closeSelectedPost,+ onClose: () => {+ if (!isDraftPostExiting) closeSelectedPost();+ },stateKey: "space-profile-viewer",});const rememberLoadedPhotoDimensions = (