Skip to content

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

perf: move splash screen to index.html

thecodrrbd151e61b166
diff --git a/apps/web/public/index.html b/apps/web/public/index.html
index 219c5188e..cc99b1dd4 100644
--- a/apps/web/public/index.html
+++ b/apps/web/public/index.html
@@ -61,12 +61,48 @@
src="https://analytics.streetwriters.co/umami.js"
data-domains="app.notesnook.com"
></script>
+ <style>
+ #splash img {
+ transform: scale(1);
+ animation: pulse 2s infinite;
+ }
+ @keyframes pulse {
+ 0% {
+ transform: scale(0.95);
+ }
+
+ 70% {
+ transform: scale(1);
+ }
+
+ 100% {
+ transform: scale(0.95);
+ }
+ }
+ </style>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/highlight.pack.min.js"></script>
-->
<div id="root"></div>
+ <div
+ id="splash"
+ style="
+ background-color: #f0f0f0;
+ height: 100%;
+ width: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ "
+ >
+ <img alt="Notesnook logo" src="./logo.svg" width="150px" />
+ </div>
<div id="dialogContainer"></div>
<!--
This HTML file is a template.
diff --git a/apps/web/src/assets/logo.svg b/apps/web/public/logo.svg
similarity index 100%
rename from apps/web/src/assets/logo.svg
rename to apps/web/public/logo.svg
diff --git a/apps/web/src/index.js b/apps/web/src/index.js
index 6c17205df..0d9b8490e 100644
--- a/apps/web/src/index.js
+++ b/apps/web/src/index.js
@@ -1,11 +1,11 @@
-import React, { Suspense } from "react";
-// import { init, showReportDialog } from "@sentry/react";
-// import { Integrations } from "@sentry/tracing";
+import React from "react";
+import { initializeDatabase } from "./common/db";
import "./index.css";
import * as serviceWorker from "./serviceWorker";
-import Splash from "./views/splash";
+// import { init, showReportDialog } from "@sentry/react";
+// import { Integrations } from "@sentry/tracing";
// import { getAppVersion } from "./utils/useVersion";
-const App = React.lazy(() => import("./App"));
+// const App = React.lazy(() => import("./App"));
// if (process.env.NODE_ENV === "production") {
// console.log = () => {};
@@ -26,26 +26,17 @@ const App = React.lazy(() => import("./App"));
// tracesSampleRate: 1.0,
// });
// }
-
-import("react-dom").then(({ render }) => {
- render(
- <Splash
- onLoadingFinished={() => {
- render(
- <Suspense fallback={<Splash noInit />}>
- <App />
- </Suspense>,
- document.getElementById("root"),
- () => {
- import("react-modal").then(({ default: Modal }) => {
- Modal.setAppElement("#root");
- });
- }
- );
- }}
- />,
- document.getElementById("root")
- );
+initializeDatabase().then(() => {
+ import("react-dom").then(({ render }) => {
+ import("./App").then(({ default: App }) => {
+ render(<App />, document.getElementById("root"), () => {
+ document.getElementById("splash").remove();
+ import("react-modal").then(({ default: Modal }) => {
+ Modal.setAppElement("#root");
+ });
+ });
+ });
+ });
});
// If you want your app to work offline and load faster, you can change
diff --git a/apps/web/src/views/splash.js b/apps/web/src/views/splash.js
deleted file mode 100644
index 9f3ecaec2..000000000
--- a/apps/web/src/views/splash.js
+++ /dev/null
@@ -1,39 +0,0 @@
-import React, { useEffect } from "react";
-import Logo from "../assets/logo.svg";
-import { initializeDatabase } from "../common/db";
-
-function Splash(props) {
- useEffect(() => {
- if (props.noInit) return;
- (async function () {
- try {
- await initializeDatabase();
- } catch (e) {
- // captureException(e, (scope) => {
- // scope.setExtra("where", "db.init");
- // return scope;
- // });
- console.error(e);
- alert(`Error initializing database: ${e.message}`);
- } finally {
- if (props.onLoadingFinished) props.onLoadingFinished();
- }
- })();
- }, []);
-
- return (
- <div
- style={{
- backgroundColor: "#f0f0f0",
- height: "100%",
- display: "flex",
- flexDirection: "column",
- justifyContent: "center",
- alignItems: "center",
- }}
- >
- <img alt="Notesnook logo" src={Logo} width={150} />
- </div>
- );
-}
-export default Splash;