Commit 7e7b265f by Sixong.Zhu

u

parent 84eafea4
Showing with 21 additions and 17 deletions
...@@ -48,10 +48,12 @@ class DevAppTools { ...@@ -48,10 +48,12 @@ class DevAppTools {
if (!this.db) { if (!this.db) {
return resolve(false); return resolve(false);
} }
const store = this.buildStore(this.table); setTimeout(() => {
const r = store.getKey(1); const store = this.buildStore(this.table);
r.onsuccess = (o) => resolve((o.target as any).result); const r = store.getKey(1);
r.onerror = () => resolve(false); r.onsuccess = (o) => resolve((o.target as any).result);
r.onerror = () => resolve(false);
}, 200);
}); });
}); });
} }
...@@ -59,19 +61,21 @@ class DevAppTools { ...@@ -59,19 +61,21 @@ class DevAppTools {
public toggle() { public toggle() {
return new Promise<boolean>((resolve) => { return new Promise<boolean>((resolve) => {
this.onReady().finally(() => { this.onReady().finally(() => {
this.isOpen().then(r => { setTimeout(() => {
if (r) { this.isOpen().then(r => {
const store = this.buildStore(this.table); if (r) {
const d = store.delete(1); const store = this.buildStore(this.table);
d.onsuccess = () => resolve(false); const d = store.delete(1);
d.onerror = () => resolve(false); d.onsuccess = () => resolve(false);
} else { d.onerror = () => resolve(false);
const store = this.buildStore(this.table); } else {
const d = store.add({ value: 1 }); const store = this.buildStore(this.table);
d.onsuccess = () => resolve(true); const d = store.add({ value: 1 });
d.onerror = () => resolve(true); d.onsuccess = () => resolve(true);
} d.onerror = () => resolve(true);
}); }
});
}, 300);
}); });
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment