aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-03 15:56:00 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-10 13:01:39 -0500
commit183ec6b3813be3bdadf87a4e3c4bbcfcc47aae60 (patch)
treeaa20c8ed69255fc2033d4a1c0e3e2d241209811a /ext
parent3a1e3392ed21205ab09e6b05f6c5beaa70e17b03 (diff)
Use native IndexedDB to delete the database
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/database.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 9810328f..b2a2007f 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -81,8 +81,9 @@ class Database {
this.db = {
backendDB: () => idb,
- close: () => {}, // Not implemented
- delete: () => {} // Not implemented
+ close: () => idb.close(),
+ get name() { return idb.name; },
+ set name(v) {}
};
}
@@ -90,7 +91,7 @@ class Database {
this.validate();
this.db.close();
- await this.db.delete();
+ await Database.deleteDatabase(this.db.name);
this.db = null;
await this.prepare();
@@ -815,4 +816,12 @@ class Database {
}
}
}
+
+ static deleteDatabase(dbName) {
+ return new Promise((resolve, reject) => {
+ const request = indexedDB.deleteDatabase(dbName);
+ request.onerror = (e) => reject(e);
+ request.onsuccess = () => resolve();
+ });
+ }
}