mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
web: fix Please unlock the key store to get values
This commit is contained in:
@@ -143,7 +143,7 @@ function isSessionExpired(path: Routes): RouteWithPath<AuthProps> | null {
|
|||||||
export async function init() {
|
export async function init() {
|
||||||
await initializeFeatureChecks();
|
await initializeFeatureChecks();
|
||||||
|
|
||||||
await await import("./utils/logger").then(({ initializeLogger }) =>
|
await import("./utils/logger").then(({ initializeLogger }) =>
|
||||||
initializeLogger()
|
initializeLogger()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { init } from "./bootstrap";
|
import { init, Routes } from "./bootstrap";
|
||||||
// import { logger } from "./utils/logger";
|
|
||||||
// import { AppEventManager, AppEvents } from "./common/app-events";
|
|
||||||
import { BaseThemeProvider } from "./components/theme-provider";
|
import { BaseThemeProvider } from "./components/theme-provider";
|
||||||
// import { register as registerStreamSaver } from "./utils/stream-saver/mitm";
|
|
||||||
// import { getServiceWorkerVersion } from "./utils/version";
|
|
||||||
import {
|
import {
|
||||||
ErrorBoundary,
|
ErrorBoundary,
|
||||||
ErrorComponent,
|
ErrorComponent,
|
||||||
@@ -31,9 +27,10 @@ import {
|
|||||||
} from "./components/error-boundary";
|
} from "./components/error-boundary";
|
||||||
import { TitleBar } from "./components/title-bar";
|
import { TitleBar } from "./components/title-bar";
|
||||||
import { desktop } from "./common/desktop-bridge";
|
import { desktop } from "./common/desktop-bridge";
|
||||||
// import { register } from "./service-worker-registration";
|
|
||||||
import { useKeyStore } from "./interfaces/key-store";
|
import { useKeyStore } from "./interfaces/key-store";
|
||||||
import Config from "./utils/config";
|
import Config from "./utils/config";
|
||||||
|
import { usePromise } from "@notesnook/common";
|
||||||
|
import { AuthProps } from "./views/auth";
|
||||||
|
|
||||||
export async function startApp() {
|
export async function startApp() {
|
||||||
const rootElement = document.getElementById("root");
|
const rootElement = document.getElementById("root");
|
||||||
@@ -51,15 +48,6 @@ export async function startApp() {
|
|||||||
|
|
||||||
await useKeyStore.getState().init();
|
await useKeyStore.getState().init();
|
||||||
|
|
||||||
await import("./hooks/use-database").then(({ loadDatabase }) =>
|
|
||||||
loadDatabase(
|
|
||||||
path !== "/sessionexpired" || Config.get("sessionExpired", false)
|
|
||||||
? "db"
|
|
||||||
: "memory"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
const { default: Component } = await component();
|
|
||||||
const { default: AppLock } = await import("./views/app-lock");
|
const { default: AppLock } = await import("./views/app-lock");
|
||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
@@ -72,7 +60,11 @@ export async function startApp() {
|
|||||||
sx={{ bg: "background", flex: 1, overflow: "hidden" }}
|
sx={{ bg: "background", flex: 1, overflow: "hidden" }}
|
||||||
>
|
>
|
||||||
<AppLock>
|
<AppLock>
|
||||||
<Component route={props?.route || "login:email"} />
|
<RouteWrapper
|
||||||
|
component={component}
|
||||||
|
path={path}
|
||||||
|
routeProps={props}
|
||||||
|
/>
|
||||||
</AppLock>
|
</AppLock>
|
||||||
</BaseThemeProvider>
|
</BaseThemeProvider>
|
||||||
</GlobalErrorHandler>
|
</GlobalErrorHandler>
|
||||||
@@ -93,30 +85,49 @@ export async function startApp() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const serviceWorkerWhitelist: Routes[] = ["default"];
|
function RouteWrapper(props: {
|
||||||
// async function initializeServiceWorker() {
|
component: () => Promise<{
|
||||||
// if (!IS_DESKTOP_APP && !IS_TESTING) {
|
default: (props: AuthProps) => JSX.Element;
|
||||||
// // logger.info("Initializing service worker...");
|
}>;
|
||||||
|
path: Routes;
|
||||||
|
routeProps: AuthProps | null;
|
||||||
|
}) {
|
||||||
|
const { component, path, routeProps } = props;
|
||||||
|
const result = usePromise(async () => {
|
||||||
|
await import("./hooks/use-database").then(({ loadDatabase }) =>
|
||||||
|
loadDatabase(
|
||||||
|
path !== "/sessionexpired" || Config.get("sessionExpired", false)
|
||||||
|
? "db"
|
||||||
|
: "memory"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// // If you want your app to work offline and load faster, you can change
|
const { default: Component } = await component();
|
||||||
// // unregister() to register() below. Note this comes with some pitfalls.
|
return Component;
|
||||||
// // Learn more about service workers: https://bit.ly/CRA-PWA
|
}, [component, path]);
|
||||||
// register({
|
|
||||||
// onUpdate: async (registration: ServiceWorkerRegistration) => {
|
if (result.status !== "fulfilled")
|
||||||
// if (!registration.waiting) return;
|
return (
|
||||||
// const { formatted } = await getServiceWorkerVersion(
|
<div
|
||||||
// registration.waiting
|
style={{
|
||||||
// );
|
backgroundColor: "var(--background)",
|
||||||
// AppEventManager.publish(AppEvents.updateDownloadCompleted, {
|
height: "100%",
|
||||||
// version: formatted
|
width: "100%",
|
||||||
// });
|
position: "absolute",
|
||||||
// },
|
top: 0,
|
||||||
// onSuccess() {
|
left: 0,
|
||||||
// registerStreamSaver();
|
display: "flex",
|
||||||
// }
|
flexDirection: "column",
|
||||||
// });
|
justifyContent: "center",
|
||||||
// // window.addEventListener("beforeinstallprompt", () => showInstallNotice());
|
alignItems: "center"
|
||||||
// }
|
}}
|
||||||
// }
|
>
|
||||||
|
<svg style={{ height: 120 }}>
|
||||||
|
<use href="#themed-logo" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
return <result.value route={routeProps?.route || "login:email"} />;
|
||||||
|
}
|
||||||
|
|
||||||
if (import.meta.hot) import.meta.hot.accept();
|
if (import.meta.hot) import.meta.hot.accept();
|
||||||
|
|||||||
Reference in New Issue
Block a user