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) {
|
||||
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 New Issue
Block a user