Persist token cache to indexedDb

This commit is contained in:
Cohee
2023-08-13 22:45:27 +03:00
parent 23a4705d36
commit e6bf870c55
2 changed files with 41 additions and 3 deletions

View File

@ -375,15 +375,18 @@ export class IndexedDBStore {
this.dbName = dbName;
this.storeName = storeName;
this.db = null;
this.version = Date.now();
}
async open() {
return new Promise((resolve, reject) => {
const request = indexedDB.open(this.dbName);
const request = indexedDB.open(this.dbName, this.version);
request.onupgradeneeded = (event) => {
const db = event.target.result;
db.createObjectStore(this.storeName, { keyPath: null, autoIncrement: false });
if (!db.objectStoreNames.contains(this.storeName)) {
db.createObjectStore(this.storeName, { keyPath: null, autoIncrement: false });
}
};
request.onsuccess = (event) => {