From c0e16ac98c45134966f45ffdda1328e24f075c6d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 12 Jul 2021 09:10:27 +0100 Subject: [PATCH] Update some more --- src/@types/spaces.ts | 4 ++-- src/client.ts | 10 +++++----- src/event-mapper.ts | 6 +++--- src/sync.ts | 3 +-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/@types/spaces.ts b/src/@types/spaces.ts index 17e677d44..da35bc0b9 100644 --- a/src/@types/spaces.ts +++ b/src/@types/spaces.ts @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { IPublicRoomsChunk } from "../client"; +import { IPublicRoomsChunkRoom } from "../client"; // Types relating to Rooms of type `m.space` and related APIs /* eslint-disable camelcase */ -export interface ISpaceSummaryRoom extends IPublicRoomsChunk { +export interface ISpaceSummaryRoom extends IPublicRoomsChunkRoom { num_refs: number; room_type: string; } diff --git a/src/client.ts b/src/client.ts index c01b2b230..321836fb6 100644 --- a/src/client.ts +++ b/src/client.ts @@ -21,7 +21,7 @@ limitations under the License. import { EventEmitter } from "events"; import { ISyncStateData, SyncApi } from "./sync"; -import { EventStatus, IContent, IDecryptOptions, MatrixEvent } from "./models/event"; +import { EventStatus, IContent, IDecryptOptions, IEvent, MatrixEvent } from "./models/event"; import { StubStore } from "./store/stub"; import { createNewMatrixCall, MatrixCall } from "./webrtc/call"; import { Filter, IFilterDefinition } from "./filter"; @@ -556,7 +556,7 @@ interface IRoomInitialSyncResponse { state?: IStateEventWithRoomId[]; visibility: Visibility; account_data?: IMinimalEvent[]; - presence: any; // undocumented + presence: Partial; // legacy and undocumented, api is deprecated so this won't get attention } interface IJoinedMembersResponse { @@ -568,7 +568,7 @@ interface IJoinedMembersResponse { }; } -export interface IPublicRoomsChunk { +export interface IPublicRoomsChunkRoom { room_id: string; name?: string; avatar_url?: string; @@ -581,7 +581,7 @@ export interface IPublicRoomsChunk { } interface IPublicRoomsResponse { - chunk: IPublicRoomsChunk[]; + chunk: IPublicRoomsChunkRoom[]; next_batch?: string; prev_batch?: string; total_room_count_estimate?: number; @@ -657,7 +657,7 @@ export interface IInstance { icon?: string; fields: object; network_id: string; - // XXX: this is undocumented but we rely on it. + // XXX: this is undocumented but we rely on it: https://github.com/matrix-org/matrix-doc/issues/3203 instance_id: string; } diff --git a/src/event-mapper.ts b/src/event-mapper.ts index 84b8b306f..e0a5e421b 100644 --- a/src/event-mapper.ts +++ b/src/event-mapper.ts @@ -15,9 +15,9 @@ limitations under the License. */ import { MatrixClient } from "./client"; -import { MatrixEvent } from "./models/event"; +import { IEvent, MatrixEvent } from "./models/event"; -export type EventMapper = (obj: any) => MatrixEvent; +export type EventMapper = (obj: Partial) => MatrixEvent; export interface MapperOpts { preventReEmit?: boolean; @@ -28,7 +28,7 @@ export function eventMapperFor(client: MatrixClient, options: MapperOpts): Event const preventReEmit = Boolean(options.preventReEmit); const decrypt = options.decrypt !== false; - function mapper(plainOldJsObject) { + function mapper(plainOldJsObject: Partial) { const event = new MatrixEvent(plainOldJsObject); if (event.isEncrypted()) { if (!preventReEmit) { diff --git a/src/sync.ts b/src/sync.ts index 3ac4489a5..863329808 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -329,8 +329,7 @@ export class SyncApi { const stateEvents = response.state.map(client.getEventMapper()); const messages = response.messages.chunk.map(client.getEventMapper()); - // XXX: copypasted from /sync until we kill off this - // minging v1 API stuff) + // XXX: copypasted from /sync until we kill off this minging v1 API stuff) // handle presence events (User objects) if (response.presence && Array.isArray(response.presence)) { response.presence.map(client.getEventMapper()).forEach(