11/*
2- Copyright 2015, 2016 OpenMarket Ltd
3- Copyright 2017 Vector Creations Ltd
4- Copyright 2018, 2019 New Vector Ltd
5- Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
2+ Copyright 2015 - 2023 The Matrix.org Foundation C.I.C.
63
74Licensed under the Apache License, Version 2.0 (the "License");
85you may not use this file except in compliance with the License.
@@ -33,6 +30,7 @@ import { CryptoEvent } from "matrix-js-sdk/src/crypto";
3330import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread" ;
3431import { HistoryVisibility } from "matrix-js-sdk/src/@types/partials" ;
3532import { ISearchResults } from "matrix-js-sdk/src/@types/search" ;
33+ import { IRoomTimelineData } from "matrix-js-sdk/src/models/event-timeline-set" ;
3634
3735import shouldHideEvent from "../../shouldHideEvent" ;
3836import { _t } from "../../languageHandler" ;
@@ -49,7 +47,7 @@ import RoomScrollStateStore, { ScrollState } from "../../stores/RoomScrollStateS
4947import WidgetEchoStore from "../../stores/WidgetEchoStore" ;
5048import SettingsStore from "../../settings/SettingsStore" ;
5149import { Layout } from "../../settings/enums/Layout" ;
52- import AccessibleButton from "../views/elements/AccessibleButton" ;
50+ import AccessibleButton , { ButtonEvent } from "../views/elements/AccessibleButton" ;
5351import RoomContext , { TimelineRenderingType } from "../../contexts/RoomContext" ;
5452import { E2EStatus , shieldStatusForRoom } from "../../utils/ShieldUtils" ;
5553import { Action } from "../../dispatcher/actions" ;
@@ -851,7 +849,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
851849 window . addEventListener ( "beforeunload" , this . onPageUnload ) ;
852850 }
853851
854- public shouldComponentUpdate ( nextProps , nextState ) : boolean {
852+ public shouldComponentUpdate ( nextProps : IRoomProps , nextState : IRoomState ) : boolean {
855853 const hasPropsDiff = objectHasDiff ( this . props , nextProps ) ;
856854
857855 const { upgradeRecommendation, ...state } = this . state ;
@@ -953,15 +951,15 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
953951 } ) ;
954952 } ;
955953
956- private onPageUnload = ( event ) : string => {
954+ private onPageUnload = ( event : BeforeUnloadEvent ) : string => {
957955 if ( ContentMessages . sharedInstance ( ) . getCurrentUploads ( ) . length > 0 ) {
958956 return ( event . returnValue = _t ( "You seem to be uploading files, are you sure you want to quit?" ) ) ;
959957 } else if ( this . getCallForRoom ( ) && this . state . callState !== "ended" ) {
960958 return ( event . returnValue = _t ( "You seem to be in a call, are you sure you want to quit?" ) ) ;
961959 }
962960 } ;
963961
964- private onReactKeyDown = ( ev ) : void => {
962+ private onReactKeyDown = ( ev : React . KeyboardEvent ) : void => {
965963 let handled = false ;
966964
967965 const action = getKeyBindingsManager ( ) . getRoomAction ( ev ) ;
@@ -1125,7 +1123,13 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
11251123 createRoomFromLocalRoom ( this . context . client , this . state . room as LocalRoom ) ;
11261124 }
11271125
1128- private onRoomTimeline = ( ev : MatrixEvent , room : Room | null , toStartOfTimeline : boolean , removed , data ) : void => {
1126+ private onRoomTimeline = (
1127+ ev : MatrixEvent ,
1128+ room : Room | null ,
1129+ toStartOfTimeline : boolean ,
1130+ removed : boolean ,
1131+ data ?: IRoomTimelineData ,
1132+ ) : void => {
11291133 if ( this . unmounted ) return ;
11301134
11311135 // ignore events for other rooms or the notification timeline set
@@ -1145,7 +1149,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
11451149
11461150 // ignore anything but real-time updates at the end of the room:
11471151 // updates from pagination will happen when the paginate completes.
1148- if ( toStartOfTimeline || ! data || ! data . liveEvent ) return ;
1152+ if ( toStartOfTimeline || ! data ? .liveEvent ) return ;
11491153
11501154 // no point handling anything while we're waiting for the join to finish:
11511155 // we'll only be showing a spinner.
@@ -1697,7 +1701,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
16971701 } ;
16981702
16991703 // update the read marker to match the read-receipt
1700- private forgetReadMarker = ( ev ) : void => {
1704+ private forgetReadMarker = ( ev : ButtonEvent ) : void => {
17011705 ev . stopPropagation ( ) ;
17021706 this . messagePanel . forgetReadMarker ( ) ;
17031707 } ;
@@ -1770,7 +1774,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
17701774 *
17711775 * We pass it down to the scroll panel.
17721776 */
1773- public handleScrollKey = ( ev ) : void => {
1777+ public handleScrollKey = ( ev : React . KeyboardEvent | KeyboardEvent ) : void => {
17741778 let panel : ScrollPanel | TimelinePanel ;
17751779 if ( this . searchResultsPanel . current ) {
17761780 panel = this . searchResultsPanel . current ;
@@ -1793,7 +1797,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
17931797
17941798 // this has to be a proper method rather than an unnamed function,
17951799 // otherwise react calls it with null on each update.
1796- private gatherTimelinePanelRef = ( r ) : void => {
1800+ private gatherTimelinePanelRef = ( r ?: TimelinePanel ) : void => {
17971801 this . messagePanel = r ;
17981802 } ;
17991803
0 commit comments