Skip to content

Commit 21792e1

Browse files
committed
noImplicitAny fixes for RoomView
Changes pulled directly from t3chguy's branch. This removes implicit `any` occurrences in `<RoomView />`. See * matrix-org#9940 * element-hq/element-web#21968 Signed-off-by: Clark Fischer <[email protected]>
1 parent 9aab7c5 commit 21792e1

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/components/structures/RoomView.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
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
74
Licensed under the Apache License, Version 2.0 (the "License");
85
you may not use this file except in compliance with the License.
@@ -33,6 +30,7 @@ import { CryptoEvent } from "matrix-js-sdk/src/crypto";
3330
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
3431
import { HistoryVisibility } from "matrix-js-sdk/src/@types/partials";
3532
import { ISearchResults } from "matrix-js-sdk/src/@types/search";
33+
import { IRoomTimelineData } from "matrix-js-sdk/src/models/event-timeline-set";
3634

3735
import shouldHideEvent from "../../shouldHideEvent";
3836
import { _t } from "../../languageHandler";
@@ -49,7 +47,7 @@ import RoomScrollStateStore, { ScrollState } from "../../stores/RoomScrollStateS
4947
import WidgetEchoStore from "../../stores/WidgetEchoStore";
5048
import SettingsStore from "../../settings/SettingsStore";
5149
import { Layout } from "../../settings/enums/Layout";
52-
import AccessibleButton from "../views/elements/AccessibleButton";
50+
import AccessibleButton, { ButtonEvent } from "../views/elements/AccessibleButton";
5351
import RoomContext, { TimelineRenderingType } from "../../contexts/RoomContext";
5452
import { E2EStatus, shieldStatusForRoom } from "../../utils/ShieldUtils";
5553
import { 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

src/components/structures/ScrollPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { createRef, CSSProperties, ReactNode, KeyboardEvent } from "react";
17+
import React, { createRef, CSSProperties, ReactNode } from "react";
1818
import { logger } from "matrix-js-sdk/src/logger";
1919

2020
import SettingsStore from "../../settings/SettingsStore";
@@ -587,7 +587,7 @@ export default class ScrollPanel extends React.Component<IProps> {
587587
* Scroll up/down in response to a scroll key
588588
* @param {object} ev the keyboard event
589589
*/
590-
public handleScrollKey = (ev: KeyboardEvent): void => {
590+
public handleScrollKey = (ev: KeyboardEvent | React.KeyboardEvent): void => {
591591
const roomAction = getKeyBindingsManager().getRoomAction(ev);
592592
switch (roomAction) {
593593
case KeyBindingAction.ScrollUp:

src/components/structures/TimelinePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
13161316
*
13171317
* We pass it down to the scroll panel.
13181318
*/
1319-
public handleScrollKey = (ev: React.KeyboardEvent): void => {
1319+
public handleScrollKey = (ev: React.KeyboardEvent | KeyboardEvent): void => {
13201320
if (!this.messagePanel.current) return;
13211321

13221322
// jump to the live timeline on ctrl-end, rather than the end of the

0 commit comments

Comments
 (0)