feat: ensure all events are loaded before create window

This commit is contained in:
Zamitto 2025-01-29 09:50:59 -03:00
parent 94a13991fa
commit f62c3f9c37
2 changed files with 13 additions and 14 deletions

View file

@ -21,7 +21,17 @@ import {
import { Auth, User, type UserPreferences } from "@types";
import { knexClient } from "./knex-client";
export const loadState = async (userPreferences: UserPreferences | null) => {
export const loadState = async () => {
const userPreferences = await migrateFromSqlite().then(async () => {
await db.put<string, boolean>(levelKeys.sqliteMigrationDone, true, {
valueEncoding: "json",
});
return db.get<string, UserPreferences>(levelKeys.userPreferences, {
valueEncoding: "json",
});
});
await import("./events");
Aria2.spawn();
@ -192,15 +202,3 @@ const migrateFromSqlite = async () => {
migrateUser,
]);
};
migrateFromSqlite().then(async () => {
await db.put<string, boolean>(levelKeys.sqliteMigrationDone, true, {
valueEncoding: "json",
});
db.get<string, UserPreferences>(levelKeys.userPreferences, {
valueEncoding: "json",
}).then((userPreferences) => {
loadState(userPreferences);
});
});