fix getKey not working on IE11

This commit is contained in:
Bruno Windels 2020-09-09 11:42:26 +01:00
parent 18a8f291dc
commit a4c8e56ab0
3 changed files with 18 additions and 8 deletions

View File

@ -42,7 +42,15 @@ export class QueryTarget {
}
getKey(key) {
if (this._target.supports("getKey")) {
return reqAsPromise(this._target.getKey(key));
} else {
return reqAsPromise(this._target.get(key)).then(value => {
if (value) {
return value[this._target.keyPath];
}
});
}
}
reduce(range, reducer, initialValue) {

View File

@ -23,6 +23,14 @@ class QueryTargetWrapper {
this._qt = qt;
}
get keyPath() {
if (this._qt.objectStore) {
return this._qt.objectStore.keyPath;
} else {
return this._qt.keyPath;
}
}
supports(methodName) {
return !!this._qt[methodName];
}

View File

@ -52,13 +52,7 @@ export class PendingEventStore {
async exists(roomId, queueIndex) {
const keyRange = IDBKeyRange.only(encodeKey(roomId, queueIndex));
let key;
if (this._eventStore.supports("getKey")) {
key = await this._eventStore.getKey(keyRange);
} else {
const value = await this._eventStore.get(keyRange);
key = value && value.key;
}
const key = await this._eventStore.getKey(keyRange);
return !!key;
}