Skip to content

Commit 09bc473

Browse files
committed
Strict mode updates for <RoomView />
This gets RoomView.ts to pass `tsc --strict`. Should be functionally unchanged. A number of other files were touched to correct signatures. See: * element-hq/element-web#23542 * element-hq/element-web#23692 Signed-off-by: Clark Fischer <clark.fischer@gmail.com>
1 parent d9a7365 commit 09bc473

File tree

8 files changed

+169
-201
lines changed

8 files changed

+169
-201
lines changed

src/components/structures/MessagePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
375375
*
376376
* returns null if we are not mounted.
377377
*/
378-
public getScrollState(): IScrollState {
378+
public getScrollState(): IScrollState | null {
379379
return this.scrollPanel.current?.getScrollState() ?? null;
380380
}
381381

src/components/structures/RoomView.tsx

Lines changed: 159 additions & 178 deletions
Large diffs are not rendered by default.

src/components/structures/TimelinePanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
698698

699699
if (!this.messagePanel.current?.getScrollState()) return;
700700

701-
if (!this.messagePanel.current.getScrollState().stuckAtBottom) {
701+
if (!this.messagePanel.current.getScrollState()?.stuckAtBottom) {
702702
// we won't load this event now, because we don't want to push any
703703
// events off the other end of the timeline. But we need to note
704704
// that we can now paginate.
@@ -1264,7 +1264,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
12641264
*
12651265
* returns null if we are not mounted.
12661266
*/
1267-
public getScrollState = (): IScrollState => {
1267+
public getScrollState = (): IScrollState | null => {
12681268
if (!this.messagePanel.current) {
12691269
return null;
12701270
}

src/components/views/rooms/RoomHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ export interface IProps {
466466
onInviteClick: (() => void) | null;
467467
onForgetClick: (() => void) | null;
468468
onAppsClick: (() => void) | null;
469-
e2eStatus: E2EStatus;
469+
e2eStatus?: E2EStatus;
470470
appsShown: boolean;
471471
searchInfo?: ISearchInfo;
472472
excludedRightPanelPhaseButtons?: Array<RightPanelPhases>;

src/components/views/rooms/SearchBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import SearchWarning, { WarningKind } from "../elements/SearchWarning";
2727

2828
interface IProps {
2929
onCancelClick: () => void;
30-
onSearch: (query: string, scope: string) => void;
30+
onSearch: (query: string, scope: SearchScope) => void;
3131
searchInProgress?: boolean;
3232
isRoomEncrypted?: boolean;
3333
}

src/dispatcher/payloads/ShowThreadPayload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Action } from "../actions";
2222
export interface ShowThreadPayload extends ActionPayload {
2323
action: Action.ShowThread;
2424

25-
rootEvent: MatrixEvent;
25+
rootEvent?: MatrixEvent;
2626
initialEvent?: MatrixEvent;
2727
highlighted?: boolean;
2828
scrollIntoView?: boolean;

src/stores/RoomScrollStateStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class RoomScrollStateStore {
3838
// from the focussedEvent.
3939
private scrollStateMap = new Map<string, ScrollState>();
4040

41-
public getScrollState(roomId: string): ScrollState {
41+
public getScrollState(roomId: string): ScrollState | undefined {
4242
return this.scrollStateMap.get(roomId);
4343
}
4444

test/components/structures/RoomView-test.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Matrix.org Foundation C.I.C.
2+
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -106,13 +106,7 @@ describe("RoomView", () => {
106106

107107
const roomView = mount(
108108
<SDKContext.Provider value={stores}>
109-
<RoomView
110-
// threepidInvite should be optional on RoomView props
111-
// it is treated as optional in RoomView
112-
threepidInvite={undefined as any}
113-
resizeNotifier={new ResizeNotifier()}
114-
forceTimeline={false}
115-
/>
109+
<RoomView resizeNotifier={new ResizeNotifier()} forceTimeline={false} />
116110
</SDKContext.Provider>,
117111
);
118112
await flushPromises();
@@ -142,14 +136,7 @@ describe("RoomView", () => {
142136

143137
const roomView = render(
144138
<SDKContext.Provider value={stores}>
145-
<RoomView
146-
// threepidInvite should be optional on RoomView props
147-
// it is treated as optional in RoomView
148-
threepidInvite={undefined as any}
149-
resizeNotifier={new ResizeNotifier()}
150-
forceTimeline={false}
151-
onRegistered={jest.fn()}
152-
/>
139+
<RoomView resizeNotifier={new ResizeNotifier()} forceTimeline={false} onRegistered={jest.fn()} />
153140
</SDKContext.Provider>,
154141
);
155142
await flushPromises();

0 commit comments

Comments
 (0)