mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
fix getKey not working on IE11
This commit is contained in:
parent
18a8f291dc
commit
a4c8e56ab0
@ -42,7 +42,15 @@ export class QueryTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getKey(key) {
|
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) {
|
reduce(range, reducer, initialValue) {
|
||||||
|
@ -23,6 +23,14 @@ class QueryTargetWrapper {
|
|||||||
this._qt = qt;
|
this._qt = qt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get keyPath() {
|
||||||
|
if (this._qt.objectStore) {
|
||||||
|
return this._qt.objectStore.keyPath;
|
||||||
|
} else {
|
||||||
|
return this._qt.keyPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
supports(methodName) {
|
supports(methodName) {
|
||||||
return !!this._qt[methodName];
|
return !!this._qt[methodName];
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,7 @@ export class PendingEventStore {
|
|||||||
|
|
||||||
async exists(roomId, queueIndex) {
|
async exists(roomId, queueIndex) {
|
||||||
const keyRange = IDBKeyRange.only(encodeKey(roomId, queueIndex));
|
const keyRange = IDBKeyRange.only(encodeKey(roomId, queueIndex));
|
||||||
let key;
|
const key = await this._eventStore.getKey(keyRange);
|
||||||
if (this._eventStore.supports("getKey")) {
|
|
||||||
key = await this._eventStore.getKey(keyRange);
|
|
||||||
} else {
|
|
||||||
const value = await this._eventStore.get(keyRange);
|
|
||||||
key = value && value.key;
|
|
||||||
}
|
|
||||||
return !!key;
|
return !!key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user