@gudhub/core 1.2.4-beta.26 → 1.2.4-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -50,7 +50,9 @@ export class IndexedDBManager {
|
|
|
50
50
|
// });
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
this.dbPrms = this.openDB();
|
|
53
|
+
// this.dbPrms = this.openDB();
|
|
54
|
+
|
|
55
|
+
this.db = null;
|
|
54
56
|
|
|
55
57
|
|
|
56
58
|
// this.db = this.openDB();
|
|
@@ -135,11 +137,11 @@ export class IndexedDBManager {
|
|
|
135
137
|
// TODO remove outdated stores before also
|
|
136
138
|
|
|
137
139
|
|
|
138
|
-
|
|
140
|
+
if (this.db) return this.db;
|
|
139
141
|
|
|
140
142
|
let resolver, rejecter;
|
|
141
143
|
|
|
142
|
-
|
|
144
|
+
let dbPrms = new Promise((resolve, reject) => {
|
|
143
145
|
resolver = resolve;
|
|
144
146
|
rejecter = reject;
|
|
145
147
|
});
|
|
@@ -169,7 +171,7 @@ export class IndexedDBManager {
|
|
|
169
171
|
// };
|
|
170
172
|
|
|
171
173
|
request.onsuccess = (event) => {
|
|
172
|
-
|
|
174
|
+
self.db = event.target.result;
|
|
173
175
|
|
|
174
176
|
// let version = this.db.version;
|
|
175
177
|
|
|
@@ -177,13 +179,15 @@ export class IndexedDBManager {
|
|
|
177
179
|
};
|
|
178
180
|
|
|
179
181
|
request.onerror = rejecter;
|
|
182
|
+
|
|
183
|
+
return dbPrms;
|
|
180
184
|
// });
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
async executeOperation(storeName, operation) {
|
|
184
188
|
|
|
185
189
|
//this get executed more than 1 time
|
|
186
|
-
await this.
|
|
190
|
+
let db = await this.openDB();
|
|
187
191
|
|
|
188
192
|
// if (
|
|
189
193
|
// !this.db
|
|
@@ -195,12 +199,12 @@ export class IndexedDBManager {
|
|
|
195
199
|
// await this.db;
|
|
196
200
|
|
|
197
201
|
|
|
198
|
-
let self = this;
|
|
202
|
+
// let self = this;
|
|
199
203
|
|
|
200
204
|
// await this.db;
|
|
201
205
|
|
|
202
206
|
return new Promise((resolve, reject) => {
|
|
203
|
-
const transaction =
|
|
207
|
+
const transaction = db.transaction(storeName, 'readwrite'); //TODO not all operations readwrite
|
|
204
208
|
const store = transaction.objectStore(storeName);
|
|
205
209
|
|
|
206
210
|
transaction.oncomplete = () => resolve();
|