forked from mystiq/hydrogen-web
fix getKey not working on IE11
This commit is contained in:
parent
18a8f291dc
commit
a4c8e56ab0
3 changed files with 18 additions and 8 deletions
|
@ -42,7 +42,15 @@ export class QueryTarget {
|
|||
}
|
||||
|
||||
getKey(key) {
|
||||
return reqAsPromise(this._target.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) {
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue