forked from akai/readest
Make sure settings are loaded before loading library, closes #2
This commit is contained in:
@@ -55,6 +55,8 @@ pub fn run() {
|
||||
let win_builder = win_builder.decorations(false).transparent(true);
|
||||
|
||||
win_builder.build().unwrap();
|
||||
// let win = win_builder.build().unwrap();
|
||||
// win.open_devtools();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
menu::setup_macos_menu(&app.handle())?;
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useState, useRef } from 'react';
|
||||
|
||||
import { useEnv } from '@/context/EnvContext';
|
||||
import { useLibraryStore } from '@/store/libraryStore';
|
||||
import { useSettingsStore } from '@/store/settingsStore';
|
||||
|
||||
import Spinner from '@/components/Spinner';
|
||||
import LibraryHeader from '@/app/library/components/LibraryHeader';
|
||||
@@ -13,6 +14,7 @@ import Bookshelf from '@/app/library/components/Bookshelf';
|
||||
const LibraryPage = () => {
|
||||
const { envConfig, appService } = useEnv();
|
||||
const { library: libraryBooks, setLibrary } = useLibraryStore();
|
||||
const { setSettings } = useSettingsStore();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const isInitiating = useRef(false);
|
||||
const [isSelectMode, setIsSelectMode] = useState(false);
|
||||
@@ -22,12 +24,17 @@ const LibraryPage = () => {
|
||||
isInitiating.current = true;
|
||||
|
||||
const loadingTimeout = setTimeout(() => setLoading(true), 200);
|
||||
envConfig.getAppService().then(async (appService) => {
|
||||
console.log('Loading library books...');
|
||||
const initLibrary = async () => {
|
||||
const appService = await envConfig.getAppService();
|
||||
const settings = await appService.loadSettings();
|
||||
setSettings(settings);
|
||||
setLibrary(await appService.loadLibraryBooks());
|
||||
|
||||
if (loadingTimeout) clearTimeout(loadingTimeout);
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
initLibrary();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ const ReaderPage = () => {
|
||||
const appService = await envConfig.getAppService();
|
||||
const settings = await appService.loadSettings();
|
||||
setSettings(settings);
|
||||
console.log('initializing library in reader');
|
||||
setLibrary(await appService.loadLibraryBooks());
|
||||
};
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@ export abstract class BaseAppService implements AppService {
|
||||
}
|
||||
|
||||
async loadLibraryBooks(): Promise<Book[]> {
|
||||
console.log('Loading library books...');
|
||||
let books: Book[] = [];
|
||||
const libraryFilename = getLibraryFilename();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user