Conform more of the codebase to strictNullChecks (#10731)
This commit is contained in:
committed by
GitHub
parent
9f8113eabd
commit
1281c0746b
@@ -62,7 +62,7 @@ export interface InteractiveAuthProps<T> {
|
||||
continueText?: string;
|
||||
continueKind?: string;
|
||||
// callback
|
||||
makeRequest(auth?: IAuthData): Promise<UIAResponse<T>>;
|
||||
makeRequest(auth: IAuthDict | null): Promise<UIAResponse<T>>;
|
||||
// callback called when the auth process has finished,
|
||||
// successfully or unsuccessfully.
|
||||
// @param {boolean} status True if the operation requiring
|
||||
@@ -200,7 +200,7 @@ export default class InteractiveAuthComponent<T> extends React.Component<Interac
|
||||
);
|
||||
};
|
||||
|
||||
private requestCallback = (auth: IAuthData | null, background: boolean): Promise<IAuthData> => {
|
||||
private requestCallback = (auth: IAuthDict | null, background: boolean): Promise<UIAResponse<T>> => {
|
||||
// This wrapper just exists because the js-sdk passes a second
|
||||
// 'busy' param for backwards compat. This throws the tests off
|
||||
// so discard it here.
|
||||
|
||||
@@ -152,15 +152,21 @@ export default class LegacyCallEventGrouper extends EventEmitter {
|
||||
};
|
||||
|
||||
public answerCall = (): void => {
|
||||
LegacyCallHandler.instance.answerCall(this.roomId);
|
||||
const roomId = this.roomId;
|
||||
if (!roomId) return;
|
||||
LegacyCallHandler.instance.answerCall(roomId);
|
||||
};
|
||||
|
||||
public rejectCall = (): void => {
|
||||
LegacyCallHandler.instance.hangupOrReject(this.roomId, true);
|
||||
const roomId = this.roomId;
|
||||
if (!roomId) return;
|
||||
LegacyCallHandler.instance.hangupOrReject(roomId, true);
|
||||
};
|
||||
|
||||
public callBack = (): void => {
|
||||
LegacyCallHandler.instance.placeCall(this.roomId, this.isVoice ? CallType.Voice : CallType.Video);
|
||||
const roomId = this.roomId;
|
||||
if (!roomId) return;
|
||||
LegacyCallHandler.instance.placeCall(roomId, this.isVoice ? CallType.Voice : CallType.Video);
|
||||
};
|
||||
|
||||
public toggleSilenced = (): void => {
|
||||
@@ -191,9 +197,10 @@ export default class LegacyCallEventGrouper extends EventEmitter {
|
||||
};
|
||||
|
||||
private setCall = (): void => {
|
||||
if (this.call) return;
|
||||
const callId = this.callId;
|
||||
if (!callId || this.call) return;
|
||||
|
||||
this.call = LegacyCallHandler.instance.getCallById(this.callId);
|
||||
this.call = LegacyCallHandler.instance.getCallById(callId);
|
||||
this.setCallListeners();
|
||||
this.setState();
|
||||
};
|
||||
|
||||
@@ -99,7 +99,7 @@ interface IProps {
|
||||
currentRoomId: string;
|
||||
collapseLhs: boolean;
|
||||
config: ConfigOptions;
|
||||
currentUserId?: string;
|
||||
currentUserId: string;
|
||||
justRegistered?: boolean;
|
||||
roomJustCreatedOpts?: IOpts;
|
||||
forceTimeline?: boolean; // see props on MatrixChat
|
||||
@@ -360,7 +360,7 @@ class LoggedInView extends React.Component<IProps, IState> {
|
||||
}
|
||||
}
|
||||
|
||||
if (pinnedEventTs && this.state.usageLimitEventTs > pinnedEventTs) {
|
||||
if (pinnedEventTs && this.state.usageLimitEventTs && this.state.usageLimitEventTs > pinnedEventTs) {
|
||||
// We've processed a newer event than this one, so ignore it.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -422,7 +422,9 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||
public componentDidUpdate(prevProps: IProps, prevState: IState): void {
|
||||
if (this.shouldTrackPageChange(prevState, this.state)) {
|
||||
const durationMs = this.stopPageChangeTimer();
|
||||
PosthogTrackers.instance.trackPageChange(this.state.view, this.state.page_type, durationMs);
|
||||
if (durationMs != null) {
|
||||
PosthogTrackers.instance.trackPageChange(this.state.view, this.state.page_type, durationMs);
|
||||
}
|
||||
}
|
||||
if (this.focusComposer) {
|
||||
dis.fire(Action.FocusSendMessageComposer);
|
||||
@@ -935,7 +937,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||
await this.firstSyncPromise.promise;
|
||||
}
|
||||
|
||||
let presentedId = roomInfo.room_alias || roomInfo.room_id;
|
||||
let presentedId = roomInfo.room_alias || roomInfo.room_id!;
|
||||
const room = MatrixClientPeg.get().getRoom(roomInfo.room_id);
|
||||
if (room) {
|
||||
// Not all timeline events are decrypted ahead of time anymore
|
||||
|
||||
@@ -308,7 +308,11 @@ export default class MessagePanel extends React.Component<IProps, IState> {
|
||||
this.calculateRoomMembersCount();
|
||||
}
|
||||
|
||||
if (prevProps.readMarkerVisible && this.props.readMarkerEventId !== prevProps.readMarkerEventId) {
|
||||
if (
|
||||
prevProps.readMarkerVisible &&
|
||||
prevProps.readMarkerEventId &&
|
||||
this.props.readMarkerEventId !== prevProps.readMarkerEventId
|
||||
) {
|
||||
const ghostReadMarkers = this.state.ghostReadMarkers;
|
||||
ghostReadMarkers.push(prevProps.readMarkerEventId);
|
||||
this.setState({
|
||||
@@ -906,7 +910,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
|
||||
if (receiptsByUserId.get(userId)) {
|
||||
continue;
|
||||
}
|
||||
const { lastShownEventId, receipt } = this.readReceiptsByUserId.get(userId);
|
||||
const { lastShownEventId, receipt } = this.readReceiptsByUserId.get(userId)!;
|
||||
const existingReceipts = receiptsByEvent.get(lastShownEventId) || [];
|
||||
receiptsByEvent.set(lastShownEventId, existingReceipts.concat(receipt));
|
||||
receiptsByUserId.set(userId, { lastShownEventId, receipt });
|
||||
|
||||
@@ -239,7 +239,7 @@ class PipContainerInner extends React.Component<IProps, IState> {
|
||||
let notDocked = false;
|
||||
// Sanity check the room - the widget may have been destroyed between render cycles, and
|
||||
// thus no room is associated anymore.
|
||||
if (persistentWidgetId && MatrixClientPeg.get().getRoom(persistentRoomId)) {
|
||||
if (persistentWidgetId && persistentRoomId && MatrixClientPeg.get().getRoom(persistentRoomId)) {
|
||||
notDocked = !ActiveWidgetStore.instance.isDocked(persistentWidgetId, persistentRoomId);
|
||||
fromAnotherRoom = this.state.viewedRoomId !== persistentRoomId;
|
||||
}
|
||||
@@ -314,10 +314,10 @@ class PipContainerInner extends React.Component<IProps, IState> {
|
||||
));
|
||||
}
|
||||
|
||||
if (this.state.showWidgetInPip) {
|
||||
if (this.state.showWidgetInPip && this.state.persistentWidgetId) {
|
||||
pipContent.push(({ onStartMoving }) => (
|
||||
<WidgetPip
|
||||
widgetId={this.state.persistentWidgetId}
|
||||
widgetId={this.state.persistentWidgetId!}
|
||||
room={MatrixClientPeg.get().getRoom(this.state.persistentRoomId ?? undefined)!}
|
||||
viewingRoom={this.state.viewedRoomId === this.state.persistentRoomId}
|
||||
onStartMoving={onStartMoving}
|
||||
|
||||
@@ -207,7 +207,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||
break;
|
||||
|
||||
case RightPanelPhases.PinnedMessages:
|
||||
if (SettingsStore.getValue("feature_pinning")) {
|
||||
if (this.props.room && SettingsStore.getValue("feature_pinning")) {
|
||||
card = (
|
||||
<PinnedMessagesCard
|
||||
room={this.props.room}
|
||||
|
||||
@@ -62,7 +62,7 @@ export default class SearchBox extends React.Component<IProps, IState> {
|
||||
|
||||
private onSearch = throttle(
|
||||
(): void => {
|
||||
this.props.onSearch(this.search.current?.value);
|
||||
this.props.onSearch(this.search.current?.value ?? "");
|
||||
},
|
||||
200,
|
||||
{ trailing: true, leading: true },
|
||||
@@ -94,11 +94,9 @@ export default class SearchBox extends React.Component<IProps, IState> {
|
||||
};
|
||||
|
||||
private clearSearch(source?: string): void {
|
||||
this.search.current.value = "";
|
||||
if (this.search.current) this.search.current.value = "";
|
||||
this.onChange();
|
||||
if (this.props.onCleared) {
|
||||
this.props.onCleared(source);
|
||||
}
|
||||
this.props.onCleared?.(source);
|
||||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { AuthType, createClient, IAuthData, IInputs, MatrixError } from "matrix-js-sdk/src/matrix";
|
||||
import { AuthType, createClient, IAuthDict, IAuthData, IInputs, MatrixError } from "matrix-js-sdk/src/matrix";
|
||||
import React, { Fragment, ReactNode } from "react";
|
||||
import { IRegisterRequestParams, IRequestTokenResponse, MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import classNames from "classnames";
|
||||
@@ -461,7 +461,7 @@ export default class Registration extends React.Component<IProps, IState> {
|
||||
});
|
||||
};
|
||||
|
||||
private makeRegisterRequest = (auth: IAuthData | null): Promise<IAuthData> => {
|
||||
private makeRegisterRequest = (auth: IAuthDict | null): Promise<IAuthData> => {
|
||||
if (!this.state.matrixClient) throw new Error("Matrix client has not yet been loaded");
|
||||
|
||||
const registerParams: IRegisterRequestParams = {
|
||||
|
||||
Reference in New Issue
Block a user