Fix bug with IDB, it should be much more stable now

This commit is contained in:
wearrrrr 2024-07-27 19:05:01 -05:00
parent 09914ab8f7
commit 0fe23c7020
4 changed files with 16 additions and 7 deletions

View file

@ -30,7 +30,6 @@
result.forEach((extension: IExtensionMetadata) => {
if (extension.type === "theme" && extension.themeName) {
// Load theme CSS
console.log("Attempting to load theme", extension.themeName);
loadStyleFromAtob(atob(extension.scriptCopy!));
document.addEventListener("astro:after-swap", () => {

View file

@ -8,7 +8,10 @@
console.log("%cBrowser: " + navigator.userAgent, `color: ${primaryColor}; font-size: 0.75rem; font-weight: bold;`);
console.log("%cCPU Cores: " + navigator.hardwareConcurrency, `color: ${primaryColor}; font-size: 0.75rem; font-weight: bold;`);
// Cmon firefox, do we really not support this?? Basic stuff here from the "indie browser".
if (!navigator.userAgent.includes("Firefox")) {
console.log("%cMemory: " + (navigator as any).deviceMemory + "GB", `color: ${primaryColor}; font-size: 0.75rem; font-weight: bold;`);
} else {
console.log("%cMemory: Not supported in Firefox", `color: ${primaryColor}; font-size: 0.75rem; font-weight: bold;`);
}
console.log("%cPlease include this information in a bug report!", `color: ${primaryColor}; font-size: 0.75rem; font-weight: bold;`);
</script>

View file

@ -21,6 +21,7 @@ export function loadIDBPromise(name: string, version: number): Promise<IDBDataba
request.onupgradeneeded = () => {
const idb = request.result;
CurrentIDB = idb;
CurrentIDB.createObjectStore(name, { keyPath: "slug" });
resolve(idb);
};

View file

@ -58,10 +58,16 @@ const { title, optionalPreloads } = Astro.props;
<script>
import IDBManager from "@components/ts/IDBManager";
if (!window.idb) {
const db = await IDBManager.loadIDBPromise("AluDB", 1);
if (db instanceof IDBDatabase) {
window.idb = db;
}
const db = IDBManager.loadIDB("AluDB", 1);
db.onupgradeneeded = () => {
window.idb = db.result;
IDBManager.SetIDB(window.idb);
IDBManager.CreateStore("InstalledExtensions", { keyPath: "slug" });
};
db.onsuccess = () => {
window.idb = db.result;
IDBManager.SetIDB(window.idb);
};
}
</script>
<meta name="generator" content={Astro.generator} />