Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load page before db load #8

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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