From 374fb08c98b702908a824ee89962f6158c6f17e9 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 24 Jan 2023 18:08:29 +0530 Subject: [PATCH] Fix typescript errors --- .../toast/BaseToastNotificationViewModel.ts | 9 ++++---- .../toast/CallToastNotificationViewModel.ts | 22 ++++++++++++------- .../session/toast/ToastCollectionViewModel.ts | 3 ++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/domain/session/toast/BaseToastNotificationViewModel.ts b/src/domain/session/toast/BaseToastNotificationViewModel.ts index 01ec688b..41e20e42 100644 --- a/src/domain/session/toast/BaseToastNotificationViewModel.ts +++ b/src/domain/session/toast/BaseToastNotificationViewModel.ts @@ -17,14 +17,15 @@ limitations under the License. import {ErrorReportViewModel} from "../../ErrorReportViewModel"; import {Options as BaseOptions} from "../../ViewModel"; import type {Session} from "../../../matrix/Session.js"; +import {SegmentType} from "../../navigation"; -export type BaseClassOptions = { +export type BaseClassOptions = { dismiss: () => void; session: Session; -} & BaseOptions; +} & BaseOptions; -export abstract class BaseToastNotificationViewModel extends ErrorReportViewModel { - constructor(options: T) { +export abstract class BaseToastNotificationViewModel = BaseClassOptions> extends ErrorReportViewModel { + constructor(options: O) { super(options); } diff --git a/src/domain/session/toast/CallToastNotificationViewModel.ts b/src/domain/session/toast/CallToastNotificationViewModel.ts index 4c005cc5..3281b86a 100644 --- a/src/domain/session/toast/CallToastNotificationViewModel.ts +++ b/src/domain/session/toast/CallToastNotificationViewModel.ts @@ -18,15 +18,21 @@ import type {Room} from "../../../matrix/room/Room.js"; import {IAvatarContract, avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl} from "../../avatar"; import {LocalMedia} from "../../../matrix/calls/LocalMedia"; import {BaseClassOptions, BaseToastNotificationViewModel} from "./BaseToastNotificationViewModel"; +import {SegmentType} from "../../navigation"; -type Options = { +type Options = { call: GroupCall; room: Room; -} & BaseClassOptions; +} & BaseClassOptions; +// Since we access the room segment below, the segment type +// needs to at least contain the room segment! +type MinimumNeededSegmentType = { + "room": string; +}; -export class CallToastNotificationViewModel extends BaseToastNotificationViewModel implements IAvatarContract { - constructor(options: Options) { +export class CallToastNotificationViewModel = Options> extends BaseToastNotificationViewModel implements IAvatarContract { + constructor(options: O) { super(options); this.track( this.call.members.subscribe({ @@ -46,8 +52,8 @@ export class CallToastNotificationViewModel extends BaseToastNotificationViewMod ); // Dismiss the toast if the room is opened manually this.track( - this.navigation.observe("room").subscribe(roomId => { - if (roomId === this.call.roomId) { + this.navigation.observe("room").subscribe((roomId) => { + if ((roomId as unknown as string) === this.call.roomId) { this.dismiss(); } })); @@ -58,8 +64,8 @@ export class CallToastNotificationViewModel extends BaseToastNotificationViewMod const stream = await this.platform.mediaDevices.getMediaTracks(false, true); const localMedia = new LocalMedia().withUserMedia(stream); await this.call.join(localMedia, log); - const url = this.urlCreator.openRoomActionUrl(this.call.roomId); - this.urlCreator.pushUrl(url); + const url = this.urlRouter.openRoomActionUrl(this.call.roomId); + this.urlRouter.pushUrl(url); }); } diff --git a/src/domain/session/toast/ToastCollectionViewModel.ts b/src/domain/session/toast/ToastCollectionViewModel.ts index 30e424ae..18b58b76 100644 --- a/src/domain/session/toast/ToastCollectionViewModel.ts +++ b/src/domain/session/toast/ToastCollectionViewModel.ts @@ -20,12 +20,13 @@ import {ViewModel, Options as BaseOptions} from "../../ViewModel"; import type {GroupCall} from "../../../matrix/calls/group/GroupCall"; import type {Room} from "../../../matrix/room/Room.js"; import type {Session} from "../../../matrix/Session.js"; +import type {SegmentType} from "../../navigation"; type Options = { session: Session; } & BaseOptions; -export class ToastCollectionViewModel extends ViewModel { +export class ToastCollectionViewModel extends ViewModel { public readonly toastViewModels: ObservableArray = new ObservableArray(); constructor(options: Options) {