fix mention in composer and improve error handling

This commit is contained in:
Ren Amamiya
2023-09-01 15:57:31 +07:00
parent cc315a190a
commit e6d35bc635
10 changed files with 156 additions and 124 deletions

View File

@@ -1,3 +1,4 @@
import { message } from '@tauri-apps/plugin-dialog';
import Database from '@tauri-apps/plugin-sql';
import { PropsWithChildren, createContext, useContext, useEffect, useState } from 'react';
@@ -15,11 +16,18 @@ const StorageProvider = ({ children }: PropsWithChildren<object>) => {
const [db, setDB] = useState<LumeStorage>(undefined);
async function initLumeStorage() {
const sqlite = await Database.load('sqlite:lume.db');
const lumeStorage = new LumeStorage(sqlite);
try {
const sqlite = await Database.load('sqlite:lume.db');
const lumeStorage = new LumeStorage(sqlite);
if (!lumeStorage.account) await lumeStorage.getActiveAccount();
setDB(lumeStorage);
if (!lumeStorage.account) await lumeStorage.getActiveAccount();
setDB(lumeStorage);
} catch (e) {
await message(`Cannot initialize database: ${e}`, {
title: 'Lume',
type: 'error',
});
}
}
useEffect(() => {