Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: fix app stuck on splash screen after logout

Abdullah Attad3e2fcc3acd9
diff --git a/apps/web/src/app-effects.tsx b/apps/web/src/app-effects.tsx
index d77cf1a52..ac52399b8 100644
--- a/apps/web/src/app-effects.tsx
+++ b/apps/web/src/app-effects.tsx
@@ -240,9 +240,6 @@ export default function AppEffects({ setShow }: AppEffectsProps) {
useEffect(() => {
introduceFeatures();
- return () => {
- EV.unsubscribeAll();
- };
}, []);
useEffect(() => {
diff --git a/apps/web/src/root.tsx b/apps/web/src/root.tsx
index 9abfd05d0..0c1201680 100644
--- a/apps/web/src/root.tsx
+++ b/apps/web/src/root.tsx
@@ -34,7 +34,7 @@ import { loadDatabase } from "./hooks/use-database";
import AppLock from "./views/app-lock";
import { Text } from "@theme-ui/components";
import { EV, EVENTS } from "@notesnook/core";
-import { useState } from "react";
+import { useEffect, useState } from "react";
export async function startApp() {
const rootElement = document.getElementById("root");
@@ -98,10 +98,16 @@ function RouteWrapper(props: {
}) {
const [isMigrating, setIsMigrating] = useState(false);
const { Component, path, routeProps } = props;
- const result = usePromise(async () => {
- EV.subscribe(EVENTS.migrationStarted, () => setIsMigrating(true), true);
- EV.subscribe(EVENTS.migrationFinished, () => setIsMigrating(false), true);
+ useEffect(() => {
+ EV.subscribe(EVENTS.migrationStarted, () => setIsMigrating(true));
+ EV.subscribe(EVENTS.migrationFinished, () => setIsMigrating(false));
+ return () => {
+ EV.unsubscribeAll();
+ };
+ }, []);
+
+ const result = usePromise(async () => {
performance.mark("load:database");
await loadDatabase(
path !== "/sessionexpired" || Config.get("sessionExpired", false)