chore: upgrade snjs deps

This commit is contained in:
Mo
2022-05-02 13:08:28 -05:00
parent 99d83af3ba
commit c2adf74ad2
6 changed files with 126 additions and 84 deletions

View File

@@ -1,4 +1,4 @@
import { SNAlertService } from '@standardnotes/snjs'
import { isString, AlertService } from '@standardnotes/snjs'
const STORE_NAME = 'items'
const READ_WRITE = 'readwrite'
@@ -19,7 +19,7 @@ export class Database {
private locked = true
private db?: IDBDatabase
constructor(public databaseName: string, private alertService: SNAlertService) {}
constructor(public databaseName: string, private alertService: AlertService) {}
public deinit() {
;(this.alertService as any) = undefined
@@ -113,6 +113,28 @@ export class Database {
})
}
public async getAllKeys(): Promise<string[]> {
const db = (await this.openDatabase()) as IDBDatabase
return new Promise((resolve) => {
const objectStore = db.transaction(STORE_NAME).objectStore(STORE_NAME)
const getAllKeysRequest = objectStore.getAllKeys()
getAllKeysRequest.onsuccess = function () {
const result = getAllKeysRequest.result
const strings = result.map((key) => {
if (isString(key)) {
return key
} else {
return JSON.stringify(key)
}
})
resolve(strings)
}
})
}
public async savePayload(payload: any): Promise<void> {
return this.savePayloads([payload])
}