Skip to content

Commit

Permalink
Strict mode updates for <RoomView />
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
clarkf committed Jan 24, 2023
1 parent d9a7365 commit 09bc473
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 201 deletions.
2 changes: 1 addition & 1 deletion src/components/structures/MessagePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
*
* returns null if we are not mounted.
*/
public getScrollState(): IScrollState {
public getScrollState(): IScrollState | null {
return this.scrollPanel.current?.getScrollState() ?? null;
}

Expand Down
337 changes: 159 additions & 178 deletions src/components/structures/RoomView.tsx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/components/structures/TimelinePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ class TimelinePanel extends React.Component<IProps, IState> {

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

if (!this.messagePanel.current.getScrollState().stuckAtBottom) {
if (!this.messagePanel.current.getScrollState()?.stuckAtBottom) {
// we won't load this event now, because we don't want to push any
// events off the other end of the timeline. But we need to note
// that we can now paginate.
Expand Down Expand Up @@ -1264,7 +1264,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
*
* returns null if we are not mounted.
*/
public getScrollState = (): IScrollState => {
public getScrollState = (): IScrollState | null => {
if (!this.messagePanel.current) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/RoomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ export interface IProps {
onInviteClick: (() => void) | null;
onForgetClick: (() => void) | null;
onAppsClick: (() => void) | null;
e2eStatus: E2EStatus;
e2eStatus?: E2EStatus;
appsShown: boolean;
searchInfo?: ISearchInfo;
excludedRightPanelPhaseButtons?: Array<RightPanelPhases>;
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import SearchWarning, { WarningKind } from "../elements/SearchWarning";

interface IProps {
onCancelClick: () => void;
onSearch: (query: string, scope: string) => void;
onSearch: (query: string, scope: SearchScope) => void;
searchInProgress?: boolean;
isRoomEncrypted?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dispatcher/payloads/ShowThreadPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Action } from "../actions";
export interface ShowThreadPayload extends ActionPayload {
action: Action.ShowThread;

rootEvent: MatrixEvent;
rootEvent?: MatrixEvent;
initialEvent?: MatrixEvent;
highlighted?: boolean;
scrollIntoView?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/stores/RoomScrollStateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class RoomScrollStateStore {
// from the focussedEvent.
private scrollStateMap = new Map<string, ScrollState>();

public getScrollState(roomId: string): ScrollState {
public getScrollState(roomId: string): ScrollState | undefined {
return this.scrollStateMap.get(roomId);
}

Expand Down
19 changes: 3 additions & 16 deletions test/components/structures/RoomView-test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -106,13 +106,7 @@ describe("RoomView", () => {

const roomView = mount(
<SDKContext.Provider value={stores}>
<RoomView
// threepidInvite should be optional on RoomView props
// it is treated as optional in RoomView
threepidInvite={undefined as any}
resizeNotifier={new ResizeNotifier()}
forceTimeline={false}
/>
<RoomView resizeNotifier={new ResizeNotifier()} forceTimeline={false} />
</SDKContext.Provider>,
);
await flushPromises();
Expand Down Expand Up @@ -142,14 +136,7 @@ describe("RoomView", () => {

const roomView = render(
<SDKContext.Provider value={stores}>
<RoomView
// threepidInvite should be optional on RoomView props
// it is treated as optional in RoomView
threepidInvite={undefined as any}
resizeNotifier={new ResizeNotifier()}
forceTimeline={false}
onRegistered={jest.fn()}
/>
<RoomView resizeNotifier={new ResizeNotifier()} forceTimeline={false} onRegistered={jest.fn()} />
</SDKContext.Provider>,
);
await flushPromises();
Expand Down

0 comments on commit 09bc473

Please sign in to comment.