From feedf96bb53344fe392c3062d00ba0aabf646ef3 Mon Sep 17 00:00:00 2001 From: cbh778899 Date: Tue, 10 Sep 2024 17:49:24 +1000 Subject: [PATCH 1/2] rename workflow Signed-off-by: cbh778899 --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5c2ebda..bb209b5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Lint code +name: Lint on: # Runs on pushes targeting the default branch From e58bcf0c9b94b4eee721d8e15f792be37aa2cc4b Mon Sep 17 00:00:00 2001 From: cbh778899 Date: Wed, 11 Sep 2024 15:11:19 +1000 Subject: [PATCH 2/2] load page after db loaded Signed-off-by: cbh778899 --- src/components/App.jsx | 16 ++++++++++++++-- src/utils/idb/index.js | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index 51ec2a1..7a5f5f8 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -1,8 +1,9 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { createBrowserRouter, Navigate, RouterProvider, } from "react-router-dom"; import Sidebar from "./sidebar"; import Chat from "./chat"; import Settings from "./Settings"; +import useIDB from "../utils/idb"; export default function App() { const router = useState(createBrowserRouter([ @@ -26,5 +27,16 @@ export default function App() { }, ]))[0]; - return + const idb = useIDB(); + const [warmup, setWarmUp] = useState(false); + + useEffect(()=>{ + (async function() { + await idb.initDB(); + setWarmUp(true); + })() + // eslint-disable-next-line + }, []) + + return warmup ? : <> } \ No newline at end of file diff --git a/src/utils/idb/index.js b/src/utils/idb/index.js index 040b1d0..4fde475 100644 --- a/src/utils/idb/index.js +++ b/src/utils/idb/index.js @@ -10,9 +10,9 @@ const defaultOptions = { } class IDB { - constructor() { - this.initDB(); - } + // constructor() { + // this.initDB(); + // } /** * Init database so that we can interact with it