From 16d3ed579b0427566f0b704e6c57d851bc9ce8c2 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 31 Aug 2021 11:41:07 -0700 Subject: [PATCH] Reduce IDBValidKey returns to the public API --- src/matrix/storage/idb/Store.ts | 8 ++++---- src/matrix/storage/idb/schema.js | 2 +- src/matrix/storage/idb/stores/InviteStore.ts | 4 ++-- src/matrix/storage/idb/stores/RoomMemberStore.ts | 4 ++-- src/matrix/storage/idb/stores/RoomSummaryStore.ts | 4 ++-- src/matrix/storage/idb/stores/SessionStore.ts | 4 ++-- src/matrix/storage/idb/stores/TimelineRelationStore.ts | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/matrix/storage/idb/Store.ts b/src/matrix/storage/idb/Store.ts index 8063a4c8..e2da0707 100644 --- a/src/matrix/storage/idb/Store.ts +++ b/src/matrix/storage/idb/Store.ts @@ -148,7 +148,7 @@ export class Store extends QueryTarget { return new QueryTarget(new QueryTargetWrapper(this._idbStore.index(indexName))); } - put(value: T): Promise { + put(value: T): void { // If this request fails, the error will bubble up to the transaction and abort it, // which is the behaviour we want. Therefore, it is ok to not create a promise for this // request and await it. @@ -159,12 +159,12 @@ export class Store extends QueryTarget { // // Note that this can still throw synchronously, like it does for TransactionInactiveError, // see https://www.w3.org/TR/IndexedDB-2/#transaction-lifetime-concept - return reqAsPromise(this._idbStore.put(value)); + this._idbStore.put(value); } - add(value: T): Promise { + add(value: T): void { // ok to not monitor result of request, see comment in `put`. - return reqAsPromise(this._idbStore.add(value)); + this._idbStore.add(value); } delete(keyOrKeyRange: IDBValidKey | IDBKeyRange): Promise { diff --git a/src/matrix/storage/idb/schema.js b/src/matrix/storage/idb/schema.js index f5472107..50e298d7 100644 --- a/src/matrix/storage/idb/schema.js +++ b/src/matrix/storage/idb/schema.js @@ -4,7 +4,7 @@ import {addRoomToIdentity} from "../../e2ee/DeviceTracker.js"; import {RoomMemberStore} from "./stores/RoomMemberStore"; import {SessionStore} from "./stores/SessionStore"; import {encodeScopeTypeKey} from "./stores/OperationStore.js"; -import {MAX_UNICODE} from "./stores/common.js"; +import {MAX_UNICODE} from "./stores/common"; // FUNCTIONS SHOULD ONLY BE APPENDED!! // the index in the array is the database version diff --git a/src/matrix/storage/idb/stores/InviteStore.ts b/src/matrix/storage/idb/stores/InviteStore.ts index f8841a71..7616ebf7 100644 --- a/src/matrix/storage/idb/stores/InviteStore.ts +++ b/src/matrix/storage/idb/stores/InviteStore.ts @@ -41,8 +41,8 @@ export class InviteStore { return this._inviteStore.selectAll(); } - set(invite: InviteData): Promise { - return this._inviteStore.put(invite); + set(invite: InviteData): void { + this._inviteStore.put(invite); } remove(roomId: string): void { diff --git a/src/matrix/storage/idb/stores/RoomMemberStore.ts b/src/matrix/storage/idb/stores/RoomMemberStore.ts index 6abd897f..e389bb77 100644 --- a/src/matrix/storage/idb/stores/RoomMemberStore.ts +++ b/src/matrix/storage/idb/stores/RoomMemberStore.ts @@ -50,10 +50,10 @@ export class RoomMemberStore { return this._roomMembersStore.get(encodeKey(roomId, userId)); } - async set(member: MemberData): Promise { + set(member: MemberData): void { // Object.assign would be more typesafe, but small objects (member as any).key = encodeKey(member.roomId, member.userId); - return this._roomMembersStore.put(member as MemberStorageEntry); + this._roomMembersStore.put(member as MemberStorageEntry); } getAll(roomId: string): Promise { diff --git a/src/matrix/storage/idb/stores/RoomSummaryStore.ts b/src/matrix/storage/idb/stores/RoomSummaryStore.ts index 19e847b1..bd911572 100644 --- a/src/matrix/storage/idb/stores/RoomSummaryStore.ts +++ b/src/matrix/storage/idb/stores/RoomSummaryStore.ts @@ -42,8 +42,8 @@ export class RoomSummaryStore { return this._summaryStore.selectAll(); } - set(summary: SummaryData): Promise { - return this._summaryStore.put(summary); + set(summary: SummaryData): void { + this._summaryStore.put(summary); } get(roomId: string): Promise { diff --git a/src/matrix/storage/idb/stores/SessionStore.ts b/src/matrix/storage/idb/stores/SessionStore.ts index 4dc467fe..859d3319 100644 --- a/src/matrix/storage/idb/stores/SessionStore.ts +++ b/src/matrix/storage/idb/stores/SessionStore.ts @@ -27,7 +27,7 @@ export class SessionStore { this._sessionStore = sessionStore; } - async get(key: IDBValidKey): Promise { + async get(key: string): Promise { const entry = await this._sessionStore.get(key); if (entry) { return entry.value; @@ -42,7 +42,7 @@ export class SessionStore { this._sessionStore.add({key, value}); } - remove(key: IDBValidKey): void { + remove(key: string): void { this._sessionStore.delete(key); } } diff --git a/src/matrix/storage/idb/stores/TimelineRelationStore.ts b/src/matrix/storage/idb/stores/TimelineRelationStore.ts index 0905eb0c..6772864a 100644 --- a/src/matrix/storage/idb/stores/TimelineRelationStore.ts +++ b/src/matrix/storage/idb/stores/TimelineRelationStore.ts @@ -39,8 +39,8 @@ export class TimelineRelationStore { this._store = store; } - add(roomId: string, targetEventId: string, relType: string, sourceEventId: string): Promise { - return this._store.add({key: encodeKey(roomId, targetEventId, relType, sourceEventId)}); + add(roomId: string, targetEventId: string, relType: string, sourceEventId: string): void { + this._store.add({key: encodeKey(roomId, targetEventId, relType, sourceEventId)}); } remove(roomId: string, targetEventId: string, relType: string, sourceEventId: string): Promise {