Skip to content

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

feat: lazy load notes

thecodrrfedc463c2190
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.js
index 92faa3d74..2c2fc1c7b 100644
--- a/apps/web/src/components/list-container/index.js
+++ b/apps/web/src/components/list-container/index.js
@@ -33,7 +33,7 @@ function ListContainer(props) {
<Flex variant="columnFill">
{!props.items.length && props.placeholder ? (
<Flex variant="columnCenterFill">
- <props.placeholder />
+ {props.isLoading ? <Icon.Loading rotate /> : <props.placeholder />}
</Flex>
) : (
<>
diff --git a/apps/web/src/views/home.js b/apps/web/src/views/home.js
index 7b20b04a0..6e8750b3a 100644
--- a/apps/web/src/views/home.js
+++ b/apps/web/src/views/home.js
@@ -1,17 +1,26 @@
-import React, { useEffect } from "react";
+import React, { useEffect, useState } from "react";
import { useStore, store } from "../stores/note-store";
import { useStore as useEditorStore } from "../stores/editor-store";
import ListContainer from "../components/list-container";
import NotesPlaceholder from "../components/placeholders/notesplacholder";
+import { db } from "../common";
function Home() {
- useEffect(() => store.refresh(), []);
+ const [isLoading, setIsLoading] = useState(true);
+ useEffect(() => {
+ (async function () {
+ await db.notes.init();
+ store.refresh();
+ setIsLoading(false);
+ })();
+ }, []);
const notes = useStore((store) => store.notes);
const newSession = useEditorStore((store) => store.newSession);
return (
<ListContainer
type="home"
+ isLoading={isLoading}
items={notes}
placeholder={NotesPlaceholder}
button={{ content: "Make a new note", onClick: () => newSession() }}
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index e58f41668..ba1ce5568 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -8953,8 +8953,8 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:
integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==
"notes-core@git+ssh://[email protected]:streetwriters/notesnook-core.git":
- version "2.4.0"
- resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#a92379da34ae59069f3e96e846b410e282efe721"
+ version "2.5.0"
+ resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#906bfaef6d69357d7e1e6df843de1c0b3fb8e339"
dependencies:
fast-sort "^2.0.1"
fuzzysearch "^1.0.3"