This commit is contained in:
Olivier Gagnon
2021-09-25 01:26:03 -04:00
parent 5c6c472b64
commit b0f20c8c8f
33 changed files with 3609 additions and 1217 deletions
+1 -14
View File
@@ -1,6 +1,3 @@
import { Engine } from "./engine";
import { createStatusText } from "./ui/createStatusText";
function getDB(): Promise<IDBObjectStore> {
return new Promise((resolve, reject) => {
if (!window.indexedDB) {
@@ -24,7 +21,7 @@ function getDB(): Promise<IDBObjectStore> {
reject(`Failed to get IDB ${ev}`);
};
indexedDbRequest.onsuccess = function (this: IDBRequest<IDBDatabase>, ev: Event) {
indexedDbRequest.onsuccess = function (this: IDBRequest<IDBDatabase>) {
const db = this.result;
if (!db) {
reject("database loadign result was undefined");
@@ -35,11 +32,6 @@ function getDB(): Promise<IDBObjectStore> {
});
}
interface ILoadCallback {
success: (s: string) => void;
error?: () => void;
}
export function load(): Promise<string> {
return new Promise(async (resolve, reject) => {
await getDB()
@@ -59,11 +51,6 @@ export function load(): Promise<string> {
});
}
interface ISaveCallback {
success: () => void;
error?: () => void;
}
export function save(saveString: string): Promise<void> {
return getDB().then((db) => {
return new Promise<void>((resolve, reject) => {