Fix bug with IDB, it should be much more stable now
This commit is contained in:
parent
09914ab8f7
commit
0fe23c7020
4 changed files with 16 additions and 7 deletions
|
|
@ -30,7 +30,6 @@
|
||||||
result.forEach((extension: IExtensionMetadata) => {
|
result.forEach((extension: IExtensionMetadata) => {
|
||||||
if (extension.type === "theme" && extension.themeName) {
|
if (extension.type === "theme" && extension.themeName) {
|
||||||
// Load theme CSS
|
// Load theme CSS
|
||||||
console.log("Attempting to load theme", extension.themeName);
|
|
||||||
loadStyleFromAtob(atob(extension.scriptCopy!));
|
loadStyleFromAtob(atob(extension.scriptCopy!));
|
||||||
|
|
||||||
document.addEventListener("astro:after-swap", () => {
|
document.addEventListener("astro:after-swap", () => {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,10 @@
|
||||||
console.log("%cBrowser: " + navigator.userAgent, `color: ${primaryColor}; font-size: 0.75rem; font-weight: bold;`);
|
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;`);
|
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".
|
// Cmon firefox, do we really not support this?? Basic stuff here from the "indie browser".
|
||||||
console.log("%cMemory: " + (navigator as any).deviceMemory + "GB", `color: ${primaryColor}; font-size: 0.75rem; font-weight: bold;`);
|
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;`);
|
console.log("%cPlease include this information in a bug report!", `color: ${primaryColor}; font-size: 0.75rem; font-weight: bold;`);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ export function loadIDBPromise(name: string, version: number): Promise<IDBDataba
|
||||||
request.onupgradeneeded = () => {
|
request.onupgradeneeded = () => {
|
||||||
const idb = request.result;
|
const idb = request.result;
|
||||||
CurrentIDB = idb;
|
CurrentIDB = idb;
|
||||||
|
CurrentIDB.createObjectStore(name, { keyPath: "slug" });
|
||||||
resolve(idb);
|
resolve(idb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,16 @@ const { title, optionalPreloads } = Astro.props;
|
||||||
<script>
|
<script>
|
||||||
import IDBManager from "@components/ts/IDBManager";
|
import IDBManager from "@components/ts/IDBManager";
|
||||||
if (!window.idb) {
|
if (!window.idb) {
|
||||||
const db = await IDBManager.loadIDBPromise("AluDB", 1);
|
const db = IDBManager.loadIDB("AluDB", 1);
|
||||||
if (db instanceof IDBDatabase) {
|
db.onupgradeneeded = () => {
|
||||||
window.idb = db;
|
window.idb = db.result;
|
||||||
}
|
IDBManager.SetIDB(window.idb);
|
||||||
|
IDBManager.CreateStore("InstalledExtensions", { keyPath: "slug" });
|
||||||
|
};
|
||||||
|
db.onsuccess = () => {
|
||||||
|
window.idb = db.result;
|
||||||
|
IDBManager.SetIDB(window.idb);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<meta name="generator" content={Astro.generator} />
|
<meta name="generator" content={Astro.generator} />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue