Commit 30bd4d34 authored by JC Brand's avatar JC Brand

Handle errors when attempting to clear IndexedDB store

parent 1653c1ae
...@@ -223,14 +223,19 @@ ...@@ -223,14 +223,19 @@
function clearIndexedDB () { function clearIndexedDB () {
const promise = u.getResolveablePromise(); const promise = u.getResolveablePromise();
const DBOpenRequest = window.indexedDB.open("converse-test-persistent"); const db_request = window.indexedDB.open("converse-test-persistent");
DBOpenRequest.onsuccess = function () { db_request.onsuccess = function () {
const db = DBOpenRequest.result; const db = db_request.result;
const bare_jid = "romeo@montague.lit"; const bare_jid = "romeo@montague.lit";
const objectStore = db.transaction([bare_jid], "readwrite").objectStore(bare_jid); try {
const objectStoreRequest = objectStore.clear(); const store= db.transaction([bare_jid], "readwrite").objectStore(bare_jid);
objectStoreRequest.onsuccess = promise.resolve(); } catch (e) {
objectStoreRequest.onerror = promise.resolve(); console.error(e);
return promise.resolve();
}
const request = store.clear();
request.onsuccess = promise.resolve();
request.onerror = promise.resolve();
}; };
return promise; return promise;
} }
......
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 to comment