A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: fix sync progress in account recovery
Abdullah Atta76237ad7dd7b
diff --git a/apps/web/src/views/recovery.tsx b/apps/web/src/views/recovery.tsxindex ca286cede..c846b9021 100644--- a/apps/web/src/views/recovery.tsx+++ b/apps/web/src/views/recovery.tsx@@ -329,23 +329,14 @@ function RecoveryMethods(props: BaseRecoveryComponentProps<"methods">) {function RecoveryKeyMethod(props: BaseRecoveryComponentProps<"method:key">) {const { navigate } = props;- const [progress, setProgress] = useState("0");+ const [progress, setProgress] = useState(0);useEffect(() => {db.eventManager.subscribe(EVENTS.syncProgress,- ({- type,- total,- current- }: {- type: string;- total: number;- current: number;- }) => {- if (total === current) return;+ ({ type, current }: { type: string; current: number }) => {if (type === "download") {- setProgress(((current / total) * 100).toFixed());+ setProgress(current);}});@@ -358,11 +349,11 @@ function RecoveryKeyMethod(props: BaseRecoveryComponentProps<"method:key">) {title="Recover your account"subtitle={"Use a data recovery key to reset your account password."}loading={{- title: `Downloading your data (${progress}%)`,+ title: `Downloading your data (${progress})`,subtitle: "Please wait while your data is downloaded & decrypted."}}onSubmit={async (form) => {- setProgress("0");+ setProgress(0);const user = await db.user?.getUser();if (!user) throw new Error("User not authenticated");@@ -479,14 +470,13 @@ function BackupData(props: BaseRecoveryComponentProps<"backup">) {function NewPassword(props: BaseRecoveryComponentProps<"new">) {const { navigate, formData } = props;- const [progress, setProgress] = useState("0");+ const [progress, setProgress] = useState(0);useEffect(() => {db.eventManager.subscribe(EVENTS.syncProgress,- ({ total, current }: { total: number; current: number }) => {- if (total === current) return;- setProgress(((current / total) * 100).toFixed());+ ({ current }: { current: number }) => {+ setProgress(current);});}, []);@@ -500,11 +490,11 @@ function NewPassword(props: BaseRecoveryComponentProps<"new">) {"Notesnook is E2E encrypted — your password never leaves this device."}loading={{- title: `Resetting account password (${progress}%)`,+ title: `Resetting account password (${progress})`,subtitle: "Please wait while we reset your account password."}}onSubmit={async (form) => {- setProgress("0");+ setProgress(0);if (form.password !== form.confirmPassword)throw new Error("Passwords do not match.");