π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix(AuthenticateUser):resolve-promises-before-closing
Aswin Asokc129a92221fb
diff --git a/web/apps/photos/src/components/AuthenticateUser.tsx b/web/apps/photos/src/components/AuthenticateUser.tsxindex 2fabc25d89..bf3b3fbc58 100644--- a/web/apps/photos/src/components/AuthenticateUser.tsx+++ b/web/apps/photos/src/components/AuthenticateUser.tsx@@ -102,8 +102,8 @@ const AuthenticateUserDialogContents: React.FC<AuthenticateUserProps> = ({keyAttributes={keyAttributes}submitButtonTitle={t("authenticate")}onVerify={() => {- onClose();onAuthenticate();+ onClose();}}/>);diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 82d964f844..f4299f1959 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -232,17 +232,41 @@ const Page: React.FC = () => {const { show: showAlbumNameInput, props: albumNameInputVisibilityProps } =useModalVisibility();- const onAuthenticateCallback = useRef<(() => void) | undefined>(undefined);+ // To resolve the pending promises when closing the AuthenticateUser modal+ const authenticateUserResolvers = useRef<{+ resolve?: () => void;+ reject?: (reason?: Error) => void;+ }>({});++ const resetAuthenticateUserResolvers = () => {+ authenticateUserResolvers.current = {};+ };const authenticateUser = useCallback(() =>- new Promise<void>((resolve) => {- onAuthenticateCallback.current = resolve;+ new Promise<void>((resolve, reject) => {+ authenticateUserResolvers.current = { resolve, reject };showAuthenticateUser();}),- [],+ [showAuthenticateUser],);+ const handleAuthenticateUserSuccess = useCallback(() => {+ authenticateUserResolvers.current.resolve?.();+ resetAuthenticateUserResolvers();+ }, []);++ const handleCloseAuthenticateUser = useCallback(() => {+ authenticateUserVisibilityProps.onClose();+ authenticateUserResolvers.current.reject?.();+ resetAuthenticateUserResolvers();+ }, [authenticateUserVisibilityProps.onClose]);++ const handleSidebarClose = useCallback(() => {+ if (authenticateUserVisibilityProps.open) return;+ sidebarVisibilityProps.onClose();+ }, [authenticateUserVisibilityProps.open, sidebarVisibilityProps.onClose]);+// Local aliases.const {user,@@ -1149,6 +1173,7 @@ const Page: React.FC = () => {/><Sidebar{...sidebarVisibilityProps}+ onClose={handleSidebarClose}normalCollectionSummaries={normalCollectionSummaries}uncategorizedCollectionSummaryID={state.uncategorizedCollectionSummaryID@@ -1218,8 +1243,9 @@ const Page: React.FC = () => {)}<Export {...exportVisibilityProps} {...{ collectionNameByID }} /><AuthenticateUser- {...authenticateUserVisibilityProps}- onAuthenticate={onAuthenticateCallback.current!}+ open={authenticateUserVisibilityProps.open}+ onClose={handleCloseAuthenticateUser}+ onAuthenticate={handleAuthenticateUserSuccess}/><SingleInputDialog{...albumNameInputVisibilityProps}