From 5d87d8bde3710c6d05c5f9530f335559f3de51e9 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 25 Jan 2022 18:43:44 +0100 Subject: [PATCH] change store.get return type when no value is found to undefined IDBRequest.result is undefined according to the official TS type decls. --- src/matrix/storage/idb/QueryTarget.ts | 4 ++-- src/matrix/storage/idb/Store.ts | 2 +- src/matrix/storage/idb/stores/AccountDataStore.ts | 2 +- src/matrix/storage/idb/stores/DeviceIdentityStore.ts | 6 +++--- .../storage/idb/stores/GroupSessionDecryptionStore.ts | 2 +- src/matrix/storage/idb/stores/InboundGroupSessionStore.ts | 2 +- src/matrix/storage/idb/stores/OlmSessionStore.ts | 2 +- src/matrix/storage/idb/stores/OutboundGroupSessionStore.ts | 2 +- src/matrix/storage/idb/stores/RoomMemberStore.ts | 2 +- src/matrix/storage/idb/stores/RoomStateStore.ts | 2 +- src/matrix/storage/idb/stores/TimelineEventStore.ts | 4 ++-- src/matrix/storage/idb/stores/TimelineFragmentStore.ts | 2 +- src/matrix/storage/idb/stores/UserIdentityStore.ts | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/matrix/storage/idb/QueryTarget.ts b/src/matrix/storage/idb/QueryTarget.ts index 26821e0f..97b85569 100644 --- a/src/matrix/storage/idb/QueryTarget.ts +++ b/src/matrix/storage/idb/QueryTarget.ts @@ -37,7 +37,7 @@ interface QueryTargetInterface { openKeyCursor(range?: IDBQuery, direction?: IDBCursorDirection | undefined): IDBRequest; supports(method: string): boolean; keyPath: string | string[]; - get(key: IDBValidKey | IDBKeyRange): IDBRequest; + get(key: IDBValidKey | IDBKeyRange): IDBRequest; getKey(key: IDBValidKey | IDBKeyRange): IDBRequest; } @@ -78,7 +78,7 @@ export class QueryTarget { return this._target.supports(methodName); } - get(key: IDBValidKey | IDBKeyRange): Promise { + get(key: IDBValidKey | IDBKeyRange): Promise { return reqAsPromise(this._target.get(key)); } diff --git a/src/matrix/storage/idb/Store.ts b/src/matrix/storage/idb/Store.ts index 07cc90b0..f45b3f3e 100644 --- a/src/matrix/storage/idb/Store.ts +++ b/src/matrix/storage/idb/Store.ts @@ -91,7 +91,7 @@ export class QueryTargetWrapper { } } - get(key: IDBValidKey | IDBKeyRange): IDBRequest { + get(key: IDBValidKey | IDBKeyRange): IDBRequest { try { LOG_REQUESTS && logRequest("get", [key], this._qt); return this._qt.get(key); diff --git a/src/matrix/storage/idb/stores/AccountDataStore.ts b/src/matrix/storage/idb/stores/AccountDataStore.ts index 32aec513..2081ad8f 100644 --- a/src/matrix/storage/idb/stores/AccountDataStore.ts +++ b/src/matrix/storage/idb/stores/AccountDataStore.ts @@ -28,7 +28,7 @@ export class AccountDataStore { this._store = store; } - async get(type: string): Promise { + async get(type: string): Promise { return await this._store.get(type); } diff --git a/src/matrix/storage/idb/stores/DeviceIdentityStore.ts b/src/matrix/storage/idb/stores/DeviceIdentityStore.ts index 6b9f5332..2936f079 100644 --- a/src/matrix/storage/idb/stores/DeviceIdentityStore.ts +++ b/src/matrix/storage/idb/stores/DeviceIdentityStore.ts @@ -17,7 +17,7 @@ limitations under the License. import {MAX_UNICODE, MIN_UNICODE} from "./common"; import {Store} from "../Store"; -interface DeviceIdentity { +export interface DeviceIdentity { userId: string; deviceId: string; ed25519Key: string; @@ -65,7 +65,7 @@ export class DeviceIdentityStore { return deviceIds; } - get(userId: string, deviceId: string): Promise { + get(userId: string, deviceId: string): Promise { return this._store.get(encodeKey(userId, deviceId)); } @@ -74,7 +74,7 @@ export class DeviceIdentityStore { this._store.put(deviceIdentity); } - getByCurve25519Key(curve25519Key: string): Promise { + getByCurve25519Key(curve25519Key: string): Promise { return this._store.index("byCurve25519Key").get(curve25519Key); } diff --git a/src/matrix/storage/idb/stores/GroupSessionDecryptionStore.ts b/src/matrix/storage/idb/stores/GroupSessionDecryptionStore.ts index 1627e44a..a73c882d 100644 --- a/src/matrix/storage/idb/stores/GroupSessionDecryptionStore.ts +++ b/src/matrix/storage/idb/stores/GroupSessionDecryptionStore.ts @@ -35,7 +35,7 @@ export class GroupSessionDecryptionStore { this._store = store; } - get(roomId: string, sessionId: string, messageIndex: number): Promise { + get(roomId: string, sessionId: string, messageIndex: number): Promise { return this._store.get(encodeKey(roomId, sessionId, messageIndex)); } diff --git a/src/matrix/storage/idb/stores/InboundGroupSessionStore.ts b/src/matrix/storage/idb/stores/InboundGroupSessionStore.ts index 22093884..c670302c 100644 --- a/src/matrix/storage/idb/stores/InboundGroupSessionStore.ts +++ b/src/matrix/storage/idb/stores/InboundGroupSessionStore.ts @@ -46,7 +46,7 @@ export class InboundGroupSessionStore { return key === fetchedKey; } - get(roomId: string, senderKey: string, sessionId: string): Promise { + get(roomId: string, senderKey: string, sessionId: string): Promise { return this._store.get(encodeKey(roomId, senderKey, sessionId)); } diff --git a/src/matrix/storage/idb/stores/OlmSessionStore.ts b/src/matrix/storage/idb/stores/OlmSessionStore.ts index 3310215e..d5a79de2 100644 --- a/src/matrix/storage/idb/stores/OlmSessionStore.ts +++ b/src/matrix/storage/idb/stores/OlmSessionStore.ts @@ -62,7 +62,7 @@ export class OlmSessionStore { }); } - get(senderKey: string, sessionId: string): Promise { + get(senderKey: string, sessionId: string): Promise { return this._store.get(encodeKey(senderKey, sessionId)); } diff --git a/src/matrix/storage/idb/stores/OutboundGroupSessionStore.ts b/src/matrix/storage/idb/stores/OutboundGroupSessionStore.ts index 9712c717..28ef23b0 100644 --- a/src/matrix/storage/idb/stores/OutboundGroupSessionStore.ts +++ b/src/matrix/storage/idb/stores/OutboundGroupSessionStore.ts @@ -32,7 +32,7 @@ export class OutboundGroupSessionStore { this._store.delete(roomId); } - get(roomId: string): Promise { + get(roomId: string): Promise { return this._store.get(roomId); } diff --git a/src/matrix/storage/idb/stores/RoomMemberStore.ts b/src/matrix/storage/idb/stores/RoomMemberStore.ts index 00cf607f..78024e7d 100644 --- a/src/matrix/storage/idb/stores/RoomMemberStore.ts +++ b/src/matrix/storage/idb/stores/RoomMemberStore.ts @@ -46,7 +46,7 @@ export class RoomMemberStore { this._roomMembersStore = roomMembersStore; } - get(roomId: string, userId: string): Promise { + get(roomId: string, userId: string): Promise { return this._roomMembersStore.get(encodeKey(roomId, userId)); } diff --git a/src/matrix/storage/idb/stores/RoomStateStore.ts b/src/matrix/storage/idb/stores/RoomStateStore.ts index b7ece0f7..d2bf811d 100644 --- a/src/matrix/storage/idb/stores/RoomStateStore.ts +++ b/src/matrix/storage/idb/stores/RoomStateStore.ts @@ -36,7 +36,7 @@ export class RoomStateStore { this._roomStateStore = idbStore; } - get(roomId: string, type: string, stateKey: string): Promise { + get(roomId: string, type: string, stateKey: string): Promise { const key = encodeKey(roomId, type, stateKey); return this._roomStateStore.get(key); } diff --git a/src/matrix/storage/idb/stores/TimelineEventStore.ts b/src/matrix/storage/idb/stores/TimelineEventStore.ts index bb6f652f..62a82fc0 100644 --- a/src/matrix/storage/idb/stores/TimelineEventStore.ts +++ b/src/matrix/storage/idb/stores/TimelineEventStore.ts @@ -301,11 +301,11 @@ export class TimelineEventStore { this._timelineStore.put(entry as TimelineEventStorageEntry); } - get(roomId: string, eventKey: EventKey): Promise { + get(roomId: string, eventKey: EventKey): Promise { return this._timelineStore.get(encodeKey(roomId, eventKey.fragmentId, eventKey.eventIndex)); } - getByEventId(roomId: string, eventId: string): Promise { + getByEventId(roomId: string, eventId: string): Promise { return this._timelineStore.index("byEventId").get(encodeEventIdKey(roomId, eventId)); } diff --git a/src/matrix/storage/idb/stores/TimelineFragmentStore.ts b/src/matrix/storage/idb/stores/TimelineFragmentStore.ts index 5753a93e..4e15589f 100644 --- a/src/matrix/storage/idb/stores/TimelineFragmentStore.ts +++ b/src/matrix/storage/idb/stores/TimelineFragmentStore.ts @@ -83,7 +83,7 @@ export class TimelineFragmentStore { this._store.put(fragment); } - get(roomId: string, fragmentId: number): Promise { + get(roomId: string, fragmentId: number): Promise { return this._store.get(encodeKey(roomId, fragmentId)); } diff --git a/src/matrix/storage/idb/stores/UserIdentityStore.ts b/src/matrix/storage/idb/stores/UserIdentityStore.ts index 692d8384..1c55baf0 100644 --- a/src/matrix/storage/idb/stores/UserIdentityStore.ts +++ b/src/matrix/storage/idb/stores/UserIdentityStore.ts @@ -28,7 +28,7 @@ export class UserIdentityStore { this._store = store; } - get(userId: string): Promise { + get(userId: string): Promise { return this._store.get(userId); }