fix: minor type and ui fixes, fix solid reactivity warning

This commit is contained in:
Samuel 2024-12-14 11:34:27 +01:00
parent d21f7fa335
commit 537c46d3d7
4 changed files with 47 additions and 35 deletions

View file

@ -1,4 +1,4 @@
import { createEffect, on } from "solid-js";
import { createEffect, createRoot, on } from "solid-js";
const DATABASE_HASH_PREFIX = "database";
@ -31,24 +31,26 @@ const HASH_STORE_KEY = "database_hash";
// cannot import `db` the normal way because this file is imported in ~/db.ts before the initialisation of `db` has happened
queueMicrotask(() => {
void import("~/db").then(({ db }) => {
createEffect(
on(db, (currentDb) => {
if (currentDb) {
const newHash = hashString(new TextDecoder().decode(currentDb.export())).toString();
createRoot(() => {
void import("~/db").then(({ db }) => {
createEffect(
on(db, (currentDb) => {
if (currentDb) {
const newHash = hashString(new TextDecoder().decode(currentDb.export())).toString();
const oldHash = localStorage.getItem(HASH_STORE_KEY);
const oldHash = localStorage.getItem(HASH_STORE_KEY);
console.log(newHash, oldHash);
console.log(newHash, oldHash);
if (newHash !== oldHash) {
clearDbCache();
if (newHash !== oldHash) {
clearDbCache();
localStorage.setItem(HASH_STORE_KEY, newHash);
localStorage.setItem(HASH_STORE_KEY, newHash);
}
}
}
}),
);
}),
);
});
});
});