From fedc463c2190a7bb514ff99d9614a95be51d61eb Mon Sep 17 00:00:00 2001 From: thecodrr Date: Tue, 24 Nov 2020 12:11:07 +0500 Subject: [PATCH] feat: lazy load notes --- apps/web/src/components/list-container/index.js | 2 +- apps/web/src/views/home.js | 13 +++++++++++-- apps/web/yarn.lock | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) 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) { {!props.items.length && props.placeholder ? ( - + {props.isLoading ? : } ) : ( <> 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 ( 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://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"