Conform more of the codebase to strict typescript (#10841)
This commit is contained in:
parent
af78a5a2f5
commit
277a3c0146
12 changed files with 89 additions and 60 deletions
|
@ -44,26 +44,37 @@ import TimelineCard from "../views/right_panel/TimelineCard";
|
|||
import { UPDATE_EVENT } from "../../stores/AsyncStore";
|
||||
import { IRightPanelCard, IRightPanelCardState } from "../../stores/right-panel/RightPanelStoreIPanelState";
|
||||
import { Action } from "../../dispatcher/actions";
|
||||
import { XOR } from "../../@types/common";
|
||||
|
||||
interface IProps {
|
||||
room?: Room; // if showing panels for a given room, this is set
|
||||
interface BaseProps {
|
||||
overwriteCard?: IRightPanelCard; // used to display a custom card and ignoring the RightPanelStore (used for UserView)
|
||||
resizeNotifier: ResizeNotifier;
|
||||
permalinkCreator?: RoomPermalinkCreator;
|
||||
e2eStatus?: E2EStatus;
|
||||
}
|
||||
|
||||
interface RoomlessProps extends BaseProps {
|
||||
room?: undefined;
|
||||
permalinkCreator?: undefined;
|
||||
}
|
||||
|
||||
interface RoomProps extends BaseProps {
|
||||
room: Room;
|
||||
permalinkCreator: RoomPermalinkCreator;
|
||||
}
|
||||
|
||||
type Props = XOR<RoomlessProps, RoomProps>;
|
||||
|
||||
interface IState {
|
||||
phase?: RightPanelPhases;
|
||||
searchQuery: string;
|
||||
cardState?: IRightPanelCardState;
|
||||
}
|
||||
|
||||
export default class RightPanel extends React.Component<IProps, IState> {
|
||||
export default class RightPanel extends React.Component<Props, IState> {
|
||||
public static contextType = MatrixClientContext;
|
||||
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||
|
||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||
public constructor(props: Props, context: React.ContextType<typeof MatrixClientContext>) {
|
||||
super(props, context);
|
||||
|
||||
this.state = {
|
||||
|
@ -89,7 +100,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
|||
RightPanelStore.instance.off(UPDATE_EVENT, this.onRightPanelStoreUpdate);
|
||||
}
|
||||
|
||||
public static getDerivedStateFromProps(props: IProps): Partial<IState> {
|
||||
public static getDerivedStateFromProps(props: Props): Partial<IState> {
|
||||
let currentCard: IRightPanelCard | undefined;
|
||||
if (props.room) {
|
||||
currentCard = RightPanelStore.instance.currentCardForRoom(props.room.roomId);
|
||||
|
@ -169,32 +180,36 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
|||
}
|
||||
break;
|
||||
case RightPanelPhases.SpaceMemberList:
|
||||
card = (
|
||||
<MemberList
|
||||
roomId={cardState?.spaceId ?? roomId}
|
||||
key={cardState?.spaceId ?? roomId}
|
||||
onClose={this.onClose}
|
||||
searchQuery={this.state.searchQuery}
|
||||
onSearchQueryChanged={this.onSearchQueryChanged}
|
||||
/>
|
||||
);
|
||||
if (!!cardState?.spaceId || !!roomId) {
|
||||
card = (
|
||||
<MemberList
|
||||
roomId={cardState?.spaceId ?? roomId!}
|
||||
key={cardState?.spaceId ?? roomId!}
|
||||
onClose={this.onClose}
|
||||
searchQuery={this.state.searchQuery}
|
||||
onSearchQueryChanged={this.onSearchQueryChanged}
|
||||
/>
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case RightPanelPhases.RoomMemberInfo:
|
||||
case RightPanelPhases.SpaceMemberInfo:
|
||||
case RightPanelPhases.EncryptionPanel: {
|
||||
const roomMember = cardState?.member instanceof RoomMember ? cardState.member : undefined;
|
||||
card = (
|
||||
<UserInfo
|
||||
user={cardState?.member}
|
||||
room={this.context.getRoom(roomMember?.roomId) ?? this.props.room}
|
||||
key={roomId ?? cardState?.member?.userId}
|
||||
onClose={this.onClose}
|
||||
phase={phase}
|
||||
verificationRequest={cardState?.verificationRequest}
|
||||
verificationRequestPromise={cardState?.verificationRequestPromise}
|
||||
/>
|
||||
);
|
||||
if (!!cardState?.member) {
|
||||
const roomMember = cardState.member instanceof RoomMember ? cardState.member : undefined;
|
||||
card = (
|
||||
<UserInfo
|
||||
user={cardState.member}
|
||||
room={this.context.getRoom(roomMember?.roomId) ?? this.props.room}
|
||||
key={roomId ?? cardState.member.userId}
|
||||
onClose={this.onClose}
|
||||
phase={phase}
|
||||
verificationRequest={cardState.verificationRequest}
|
||||
verificationRequestPromise={cardState.verificationRequestPromise}
|
||||
/>
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RightPanelPhases.Room3pidMemberInfo:
|
||||
|
@ -261,10 +276,10 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
|||
break;
|
||||
|
||||
case RightPanelPhases.ThreadPanel:
|
||||
if (!!roomId) {
|
||||
if (!!this.props.room) {
|
||||
card = (
|
||||
<ThreadPanel
|
||||
roomId={roomId}
|
||||
roomId={this.props.room.roomId}
|
||||
resizeNotifier={this.props.resizeNotifier}
|
||||
onClose={this.onClose}
|
||||
permalinkCreator={this.props.permalinkCreator}
|
||||
|
|
|
@ -1488,6 +1488,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
// rate limited because a power level change will emit an event for every member in the room.
|
||||
private updateRoomMembers = throttle(
|
||||
() => {
|
||||
if (!this.state.room) return;
|
||||
this.updateDMState();
|
||||
this.updateE2EStatus(this.state.room);
|
||||
},
|
||||
|
|
|
@ -740,7 +740,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.
|
||||
|
@ -981,7 +981,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
|||
{ leading: true, trailing: true },
|
||||
);
|
||||
|
||||
private readMarkerTimeout(readMarkerPosition: number): number {
|
||||
private readMarkerTimeout(readMarkerPosition: number | null): number {
|
||||
return readMarkerPosition === 0
|
||||
? this.context?.readMarkerInViewThresholdMs ?? this.state.readMarkerInViewThresholdMs
|
||||
: this.context?.readMarkerOutOfViewThresholdMs ?? this.state.readMarkerOutOfViewThresholdMs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue