From 29c87b7c01b66eca97fc35b478d8f4d007fc647f Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 11 Aug 2021 12:03:06 -0700 Subject: [PATCH] Add initial translation of InviteStore.js --- src/matrix/storage/idb/Transaction.js | 2 +- .../stores/{InviteStore.js => InviteStore.ts} | 32 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) rename src/matrix/storage/idb/stores/{InviteStore.js => InviteStore.ts} (53%) diff --git a/src/matrix/storage/idb/Transaction.js b/src/matrix/storage/idb/Transaction.js index c92999b8..e3189283 100644 --- a/src/matrix/storage/idb/Transaction.js +++ b/src/matrix/storage/idb/Transaction.js @@ -19,7 +19,7 @@ import {StorageError} from "../common"; import {Store} from "./Store"; import {SessionStore} from "./stores/SessionStore"; import {RoomSummaryStore} from "./stores/RoomSummaryStore"; -import {InviteStore} from "./stores/InviteStore.js"; +import {InviteStore} from "./stores/InviteStore"; import {TimelineEventStore} from "./stores/TimelineEventStore.js"; import {TimelineRelationStore} from "./stores/TimelineRelationStore.js"; import {RoomStateStore} from "./stores/RoomStateStore.js"; diff --git a/src/matrix/storage/idb/stores/InviteStore.js b/src/matrix/storage/idb/stores/InviteStore.ts similarity index 53% rename from src/matrix/storage/idb/stores/InviteStore.js rename to src/matrix/storage/idb/stores/InviteStore.ts index b0eefe60..971d3fe3 100644 --- a/src/matrix/storage/idb/stores/InviteStore.js +++ b/src/matrix/storage/idb/stores/InviteStore.ts @@ -13,21 +13,45 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +import {Store} from "../Store" + +// TODO: Move to Invite when that's TypeScript. +interface InviteData { + roomId: string + isEncrypted: boolean + isDirectMessage: boolean + name?: string + avatarUrl?: string + avatarColorId: number + canonicalAlias?: string + timestamp: number + joinRule: string + inviter?: MemberData +} + +// TODO: Move to RoomMember when that's TypeScript. +interface MemberData { + roomId: string + userId: string + membership: "join" | "leave" | "invite" | "ban" +} export class InviteStore { - constructor(inviteStore) { + private _inviteStore: Store + + constructor(inviteStore: Store) { this._inviteStore = inviteStore; } - getAll() { + getAll(): Promise { return this._inviteStore.selectAll(); } - set(invite) { + set(invite: InviteData): void { return this._inviteStore.put(invite); } - remove(roomId) { + remove(roomId: string): void { this._inviteStore.delete(roomId); } }