Conform more code to strictNullChecks
(#10374)
* Apply `strictNullChecks` to `src/components/views/room_settings/*` * Restore tsconfig.json * Conform more code to `strictNullChecks` * Iterate * Update matrix-widget-api * Conform more code to `strictNullChecks`
This commit is contained in:
parent
9c816bb720
commit
1c9ea423c9
44 changed files with 223 additions and 179 deletions
|
@ -47,10 +47,10 @@ interface IProps {
|
|||
room: Room;
|
||||
onClose: () => void;
|
||||
resizeNotifier: ResizeNotifier;
|
||||
permalinkCreator?: RoomPermalinkCreator;
|
||||
permalinkCreator: RoomPermalinkCreator;
|
||||
e2eStatus?: E2EStatus;
|
||||
classNames?: string;
|
||||
timelineSet?: EventTimelineSet;
|
||||
timelineSet: EventTimelineSet;
|
||||
timelineRenderingType?: TimelineRenderingType;
|
||||
showComposer?: boolean;
|
||||
composerRelation?: IEventRelation;
|
||||
|
@ -77,7 +77,7 @@ export default class TimelineCard extends React.Component<IProps, IState> {
|
|||
private layoutWatcherRef: string;
|
||||
private timelinePanel = React.createRef<TimelinePanel>();
|
||||
private card = React.createRef<HTMLDivElement>();
|
||||
private readReceiptsSettingWatcher: string;
|
||||
private readReceiptsSettingWatcher: string | undefined;
|
||||
|
||||
public constructor(props: IProps) {
|
||||
super(props);
|
||||
|
@ -87,7 +87,6 @@ export default class TimelineCard extends React.Component<IProps, IState> {
|
|||
atEndOfLiveTimeline: true,
|
||||
narrow: false,
|
||||
};
|
||||
this.readReceiptsSettingWatcher = null;
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
|
@ -129,7 +128,7 @@ export default class TimelineCard extends React.Component<IProps, IState> {
|
|||
case Action.EditEvent:
|
||||
this.setState(
|
||||
{
|
||||
editState: payload.event ? new EditorStateTransfer(payload.event) : null,
|
||||
editState: payload.event ? new EditorStateTransfer(payload.event) : undefined,
|
||||
},
|
||||
() => {
|
||||
if (payload.event) {
|
||||
|
@ -199,7 +198,7 @@ export default class TimelineCard extends React.Component<IProps, IState> {
|
|||
};
|
||||
|
||||
public render(): React.ReactNode {
|
||||
const highlightedEventId = this.state.isInitialEventHighlighted ? this.state.initialEventId : null;
|
||||
const highlightedEventId = this.state.isInitialEventHighlighted ? this.state.initialEventId : undefined;
|
||||
|
||||
let jumpToBottom;
|
||||
if (!this.state.atEndOfLiveTimeline) {
|
||||
|
@ -232,7 +231,7 @@ export default class TimelineCard extends React.Component<IProps, IState> {
|
|||
header={this.renderTimelineCardHeader()}
|
||||
ref={this.card}
|
||||
>
|
||||
<Measured sensor={this.card.current} onMeasurement={this.onMeasurement} />
|
||||
{this.card.current && <Measured sensor={this.card.current} onMeasurement={this.onMeasurement} />}
|
||||
<div className="mx_TimelineCard_timeline">
|
||||
{jumpToBottom}
|
||||
<TimelinePanel
|
||||
|
|
|
@ -69,8 +69,9 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
const showQR: boolean = request.otherPartySupportsMethod(SCAN_QR_CODE_METHOD);
|
||||
const brand = SdkConfig.get().brand;
|
||||
|
||||
const noCommonMethodError: JSX.Element =
|
||||
!showSAS && !showQR ? (
|
||||
let noCommonMethodError: JSX.Element | undefined;
|
||||
if (!showSAS && !showQR) {
|
||||
noCommonMethodError = (
|
||||
<p>
|
||||
{_t(
|
||||
"The device you are trying to verify doesn't support scanning a " +
|
||||
|
@ -79,12 +80,13 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
{ brand },
|
||||
)}
|
||||
</p>
|
||||
) : null;
|
||||
);
|
||||
}
|
||||
|
||||
if (this.props.layout === "dialog") {
|
||||
// HACK: This is a terrible idea.
|
||||
let qrBlockDialog: JSX.Element;
|
||||
let sasBlockDialog: JSX.Element;
|
||||
let qrBlockDialog: JSX.Element | undefined;
|
||||
let sasBlockDialog: JSX.Element | undefined;
|
||||
if (showQR) {
|
||||
qrBlockDialog = (
|
||||
<div className="mx_VerificationPanel_QRPhase_startOption">
|
||||
|
@ -132,7 +134,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
);
|
||||
}
|
||||
|
||||
let qrBlock: JSX.Element;
|
||||
let qrBlock: JSX.Element | undefined;
|
||||
if (showQR) {
|
||||
qrBlock = (
|
||||
<div className="mx_UserInfo_container">
|
||||
|
@ -150,7 +152,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
);
|
||||
}
|
||||
|
||||
let sasBlock: JSX.Element;
|
||||
let sasBlock: JSX.Element | undefined;
|
||||
if (showSAS) {
|
||||
const disabled = this.state.emojiButtonClicked;
|
||||
const sasLabel = showQR
|
||||
|
@ -189,18 +191,20 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
}
|
||||
|
||||
private onReciprocateYesClick = (): void => {
|
||||
if (!this.state.reciprocateQREvent) return;
|
||||
this.setState({ reciprocateButtonClicked: true });
|
||||
this.state.reciprocateQREvent.confirm();
|
||||
};
|
||||
|
||||
private onReciprocateNoClick = (): void => {
|
||||
if (!this.state.reciprocateQREvent) return;
|
||||
this.setState({ reciprocateButtonClicked: true });
|
||||
this.state.reciprocateQREvent.cancel();
|
||||
};
|
||||
|
||||
private getDevice(): DeviceInfo {
|
||||
const deviceId = this.props.request && this.props.request.channel.deviceId;
|
||||
return MatrixClientPeg.get().getStoredDevice(MatrixClientPeg.get().getUserId(), deviceId);
|
||||
private getDevice(): DeviceInfo | null {
|
||||
const cli = MatrixClientPeg.get();
|
||||
return cli.getStoredDevice(cli.getSafeUserId(), this.props.request?.channel.deviceId);
|
||||
}
|
||||
|
||||
private renderQRReciprocatePhase(): JSX.Element {
|
||||
|
@ -253,7 +257,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
private renderVerifiedPhase(): JSX.Element {
|
||||
const { member, request } = this.props;
|
||||
|
||||
let text: string;
|
||||
let text: string | undefined;
|
||||
if (!request.isSelfVerification) {
|
||||
if (this.props.isRoomEncrypted) {
|
||||
text = _t("Verify all users in a room to ensure it's secure.");
|
||||
|
@ -348,7 +352,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
const emojis = this.state.sasEvent ? (
|
||||
<VerificationShowSas
|
||||
displayName={displayName}
|
||||
device={this.getDevice()}
|
||||
device={this.getDevice() ?? undefined}
|
||||
sas={this.state.sasEvent.sas}
|
||||
onCancel={this.onSasMismatchesClick}
|
||||
onDone={this.onSasMatchesClick}
|
||||
|
@ -383,11 +387,11 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
};
|
||||
|
||||
private onSasMatchesClick = (): void => {
|
||||
this.state.sasEvent.confirm();
|
||||
this.state.sasEvent?.confirm();
|
||||
};
|
||||
|
||||
private onSasMismatchesClick = (): void => {
|
||||
this.state.sasEvent.mismatch();
|
||||
this.state.sasEvent?.mismatch();
|
||||
};
|
||||
|
||||
private updateVerifierState = (): void => {
|
||||
|
|
|
@ -55,9 +55,9 @@ const WidgetCard: React.FC<IProps> = ({ room, widgetId, onClose }) => {
|
|||
// Don't render anything as we are about to transition
|
||||
if (!app || !isRight) return null;
|
||||
|
||||
let contextMenu;
|
||||
let contextMenu: JSX.Element | undefined;
|
||||
if (menuDisplayed) {
|
||||
const rect = handle.current.getBoundingClientRect();
|
||||
const rect = handle.current!.getBoundingClientRect();
|
||||
contextMenu = (
|
||||
<WidgetContextMenu
|
||||
chevronFace={ChevronFace.None}
|
||||
|
@ -92,7 +92,7 @@ const WidgetCard: React.FC<IProps> = ({ room, widgetId, onClose }) => {
|
|||
fullWidth
|
||||
showMenubar={false}
|
||||
room={room}
|
||||
userId={cli.getUserId()}
|
||||
userId={cli.getSafeUserId()}
|
||||
creatorUserId={app.creatorUserId}
|
||||
widgetPageTitle={WidgetUtils.getWidgetDataTitle(app)}
|
||||
waitForIframeLoad={app.waitForIframeLoad}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue