π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
State reset
Manav Rathie856a653b8b3
diff --git a/web/apps/photos/src/components/AuthenticateUser.tsx b/web/apps/photos/src/components/AuthenticateUser.tsxindex 2d476ccce6..a1559f7b83 100644--- a/web/apps/photos/src/components/AuthenticateUser.tsx+++ b/web/apps/photos/src/components/AuthenticateUser.tsx@@ -30,11 +30,32 @@ type AuthenticateUserProps = ModalVisibilityProps & {* This is used as precursor to performing various sensitive or locked actions.*/export const AuthenticateUser: React.FC<AuthenticateUserProps> = ({+ open,+ onClose,+ ...rest+}) => (+ <TitledMiniDialog+ open={open}+ onClose={onClose}+ sx={{ position: "absolute" }}+ title={t("password")}+ >+ <AuthenticateUserDialogContents {...{ open, onClose }} {...rest} />+ </TitledMiniDialog>+);++/**+ * The contents of the {@link AuthenticateUser} dialog.+ *+ * See: [Note: MUI dialog state] for why this is a separate component.+ */+const AuthenticateUserDialogContents: React.FC<AuthenticateUserProps> = ({open,onClose,onAuthenticate,}) => {const { logout, showMiniDialog } = useBaseContext();+const [user, setUser] = useState<LocalUser | undefined>();const [keyAttributes, setKeyAttributes] = useState<KeyAttributes | undefined@@ -76,22 +97,15 @@ export const AuthenticateUser: React.FC<AuthenticateUserProps> = ({if (!user && !keyAttributes) return <></>;return (- <TitledMiniDialog- open={open}- onClose={onClose}- sx={{ position: "absolute" }}- title={t("password")}- >- <VerifyMasterPasswordForm- userEmail={user.email}- keyAttributes={keyAttributes}- submitButtonTitle={t("authenticate")}- onVerify={() => {- onClose();- onAuthenticate();- }}- />- </TitledMiniDialog>+ <VerifyMasterPasswordForm+ userEmail={user.email}+ keyAttributes={keyAttributes}+ submitButtonTitle={t("authenticate")}+ onVerify={() => {+ onClose();+ onAuthenticate();+ }}+ />);};diff --git a/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx b/web/apps/photos/src/components/Collections/AlbumCastDialog.tsxindex f14f0d7cc8..78d44cba1e 100644--- a/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx+++ b/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx@@ -40,11 +40,15 @@ export const AlbumCastDialog: React.FC<AlbumCastDialogProps> = ({);/**- * [Note: MUI dialog state reset]+ * [Note: MUI dialog state]*- * Keep the dialog contents in a separate component so that they get rendered+ * In some cases we keep the dialog contents in a separate component so that (a)+ * they get rendered only when the dialog is shown, and (b) they get rendered* afresh when the dialog is unmounted and then shown again.*+ * Keeping it separate both resets the state of the component, and also ensures+ * that the effects run again when the dialog is shown.+ ** Details:** Any state we keep inside the React component that a MUI Dialog as a child@@ -58,7 +62,8 @@ export const AlbumCastDialog: React.FC<AlbumCastDialogProps> = ({* circumstance. If it is undesirable, there are multiple approaches:* https://github.com/mui/material-ui/issues/16325*- * One of those is to keep the dialog contents in a separate component.+ * One of those approaches is to keep the dialog contents in a separate+ * component.*/export const AlbumCastDialogContents: React.FC<AlbumCastDialogProps> = ({open,diff --git a/web/packages/new/photos/components/DeleteAccount.tsx b/web/packages/new/photos/components/DeleteAccount.tsxindex abf3980c30..4bc8ad3584 100644--- a/web/packages/new/photos/components/DeleteAccount.tsx+++ b/web/packages/new/photos/components/DeleteAccount.tsx@@ -47,7 +47,11 @@ export const DeleteAccount: React.FC<DeleteAccountProps> = ({</TitledMiniDialog>);-// See: [Note: MUI dialog state reset]+/**+ * The contents of the {@link DeleteAccount} dialog.+ *+ * See: [Note: MUI dialog state] for why this is a separate component.+ */const DeleteAccountDialogContents: React.FC<Omit<DeleteAccountProps, "open">> = ({ onClose, onAuthenticateUser }) => {