From eb7fcc6da2eaabcf216b96d1c4fd59e15ea7f012 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 24 Jan 2023 13:24:15 +0530 Subject: [PATCH] Add return types --- .../session/toast/ToastCollectionViewModel.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/domain/session/toast/ToastCollectionViewModel.ts b/src/domain/session/toast/ToastCollectionViewModel.ts index 3860830d..30e424ae 100644 --- a/src/domain/session/toast/ToastCollectionViewModel.ts +++ b/src/domain/session/toast/ToastCollectionViewModel.ts @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ +import {CallToastNotificationViewModel} from "./CallToastNotificationViewModel"; import {ObservableArray} from "../../../observable"; 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 {CallToastNotificationViewModel} from "./CallToastNotificationViewModel"; type Options = { session: Session; @@ -35,8 +35,8 @@ export class ToastCollectionViewModel extends ViewModel { this.track(callsObservableMap.subscribe(this)); } - onAdd(_, call) { - if (this.shouldShowNotification(call)) { + onAdd(_, call: GroupCall) { + if (this._shouldShowNotification(call)) { const room = this._findRoomForCall(call); const dismiss = () => { const idx = this.toastViewModels.array.findIndex(vm => vm.call === call); @@ -50,17 +50,16 @@ export class ToastCollectionViewModel extends ViewModel { } } - onRemove(_, call) { + onRemove(_, call: GroupCall) { const idx = this.toastViewModels.array.findIndex(vm => vm.call === call); if (idx !== -1) { this.toastViewModels.remove(idx); } } - onUpdate(_, call) { + onUpdate(_, call: GroupCall) { const idx = this.toastViewModels.array.findIndex(vm => vm.call === call); if (idx !== -1) { - // todo: is this correct? this.toastViewModels.update(idx, this.toastViewModels.at(idx)!); } } @@ -77,7 +76,7 @@ export class ToastCollectionViewModel extends ViewModel { return rooms.get(id); } - private shouldShowNotification(call: GroupCall): boolean { + private _shouldShowNotification(call: GroupCall): boolean { const currentlyOpenedRoomId = this.navigation.path.get("room")?.value; if (!call.isLoadedFromStorage && call.roomId !== currentlyOpenedRoomId) { return true;