feat: lazy load notes

This commit is contained in:
thecodrr
2020-11-24 12:11:07 +05:00
parent 201d22b43f
commit fedc463c21
3 changed files with 14 additions and 5 deletions

View File

@@ -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>
) : (
<>

View File

@@ -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() }}

View File

@@ -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://git@github.com:streetwriters/notesnook-core.git":
version "2.4.0"
resolved "git+ssh://git@github.com:streetwriters/notesnook-core.git#a92379da34ae59069f3e96e846b410e282efe721"
version "2.5.0"
resolved "git+ssh://git@github.com:streetwriters/notesnook-core.git#906bfaef6d69357d7e1e6df843de1c0b3fb8e339"
dependencies:
fast-sort "^2.0.1"
fuzzysearch "^1.0.3"