diff --git a/src/matrix/storage/idb/query-target.js b/src/matrix/storage/idb/query-target.js index fa5b99f5..7e848218 100644 --- a/src/matrix/storage/idb/query-target.js +++ b/src/matrix/storage/idb/query-target.js @@ -17,6 +17,10 @@ export default class QueryTarget { } } + supports(methodName) { + return this._target.supports(methodName); + } + get(key) { return reqAsPromise(this._target.get(key)); } diff --git a/src/matrix/storage/idb/store.js b/src/matrix/storage/idb/store.js index 58709573..1b4d3733 100644 --- a/src/matrix/storage/idb/store.js +++ b/src/matrix/storage/idb/store.js @@ -6,6 +6,10 @@ class QueryTargetWrapper { constructor(qt) { this._qt = qt; } + + supports(methodName) { + return !!this._qt[methodName]; + } openKeyCursor(...params) { try { diff --git a/src/matrix/storage/idb/stores/PendingEventStore.js b/src/matrix/storage/idb/stores/PendingEventStore.js index d73b649e..d413ec63 100644 --- a/src/matrix/storage/idb/stores/PendingEventStore.js +++ b/src/matrix/storage/idb/stores/PendingEventStore.js @@ -36,7 +36,13 @@ export default class PendingEventStore { async exists(roomId, queueIndex) { const keyRange = IDBKeyRange.only(encodeKey(roomId, queueIndex)); - const key = await this._eventStore.getKey(keyRange); + 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; + } return !!key; }