Skip to content

Commit

Permalink
Merge pull request #8 from SkywardAI/db-load
Browse files Browse the repository at this point in the history
load page before db load
  • Loading branch information
cbh778899 authored Sep 11, 2024
2 parents c4d5037 + e58bcf0 commit 09c6726
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint code
name: Lint

on:
# Runs on pushes targeting the default branch
Expand Down
16 changes: 14 additions & 2 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
@@ -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([
Expand All @@ -26,5 +27,16 @@ export default function App() {
},
]))[0];

return <RouterProvider router={router} />
const idb = useIDB();
const [warmup, setWarmUp] = useState(false);

useEffect(()=>{
(async function() {
await idb.initDB();
setWarmUp(true);
})()
// eslint-disable-next-line
}, [])

return warmup ? <RouterProvider router={router} /> : <></>
}
6 changes: 3 additions & 3 deletions src/utils/idb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const defaultOptions = {
}

class IDB {
constructor() {
this.initDB();
}
// constructor() {
// this.initDB();
// }

/**
* Init database so that we can interact with it
Expand Down

0 comments on commit 09c6726

Please sign in to comment.