Database class cleanup

This commit is contained in:
Mo Bitar
2020-03-25 16:33:03 -05:00
parent 7aa38cbdb8
commit a80a94de5e
5 changed files with 544 additions and 515 deletions

View File

@@ -25,6 +25,12 @@ export class WebDeviceInterface extends DeviceInterface {
this.database.setApplication(application);
}
/** @override */
deinit() {
super.deinit();
this.database.deinit();
}
/**
* @value storage
*/
@@ -56,22 +62,14 @@ export class WebDeviceInterface extends DeviceInterface {
localStorage.clear();
}
/**
* @database
*/
async openDatabase() {
this.database.setLocked(false);
this.database.openDatabase({
onUpgradeNeeded: () => {
/**
* New database/database wiped, delete syncToken so that items
* can be refetched entirely from server
*/
/** @todo notify parent */
// this.syncManager.clearSyncPositionTokens();
// this.sync();
}
this.database.unlock();
return new Promise((resolve) => {
this.database.openDatabase(() => {
resolve({ isNewDatabase: true });
}).then(() => {
resolve({ isNewDatabase: false });
});
});
}
@@ -112,7 +110,7 @@ export class WebDeviceInterface extends DeviceInterface {
/** @keychian */
async getKeychainValue() {
const value = localStorage.getItem(KEYCHAIN_STORAGE_KEY);
if(value) {
if (value) {
return JSON.parse(value);
}
}