Conform more of the codebase to strictNullChecks (#10672)
* Conform more of the codebase to `strictNullChecks` * Iterate * Iterate * Iterate * Iterate * Conform more of the codebase to `strictNullChecks` * Iterate * Update record key
This commit is contained in:
parent
792a39a39b
commit
be5928cb64
34 changed files with 143 additions and 115 deletions
|
@ -65,11 +65,11 @@ export const OverflowMenuContext = createContext<OverflowMenuCloser | null>(null
|
|||
|
||||
const MessageComposerButtons: React.FC<IProps> = (props: IProps) => {
|
||||
const matrixClient = useContext(MatrixClientContext);
|
||||
const { room, roomId, narrow } = useContext(RoomContext);
|
||||
const { room, narrow } = useContext(RoomContext);
|
||||
|
||||
const isWysiwygLabEnabled = useSettingValue<boolean>("feature_wysiwyg_composer");
|
||||
|
||||
if (props.haveRecording) {
|
||||
if (!matrixClient || !room || props.haveRecording) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ const MessageComposerButtons: React.FC<IProps> = (props: IProps) => {
|
|||
voiceRecordingButton(props, narrow),
|
||||
startVoiceBroadcastButton(props),
|
||||
props.showPollsButton ? pollButton(room, props.relation) : null,
|
||||
showLocationButton(props, room, roomId, matrixClient),
|
||||
showLocationButton(props, room, matrixClient),
|
||||
];
|
||||
} else {
|
||||
mainButtons = [
|
||||
|
@ -113,7 +113,7 @@ const MessageComposerButtons: React.FC<IProps> = (props: IProps) => {
|
|||
voiceRecordingButton(props, narrow),
|
||||
startVoiceBroadcastButton(props),
|
||||
props.showPollsButton ? pollButton(room, props.relation) : null,
|
||||
showLocationButton(props, room, roomId, matrixClient),
|
||||
showLocationButton(props, room, matrixClient),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ const MessageComposerButtons: React.FC<IProps> = (props: IProps) => {
|
|||
});
|
||||
|
||||
return (
|
||||
<UploadButtonContextProvider roomId={roomId} relation={props.relation}>
|
||||
<UploadButtonContextProvider roomId={room.roomId} relation={props.relation}>
|
||||
{mainButtons}
|
||||
{moreButtons.length > 0 && (
|
||||
<AccessibleTooltipButton
|
||||
|
@ -346,18 +346,13 @@ class PollButton extends React.PureComponent<IPollButtonProps> {
|
|||
}
|
||||
}
|
||||
|
||||
function showLocationButton(
|
||||
props: IProps,
|
||||
room: Room,
|
||||
roomId: string,
|
||||
matrixClient: MatrixClient,
|
||||
): ReactElement | null {
|
||||
const sender = room.getMember(matrixClient.getUserId()!);
|
||||
function showLocationButton(props: IProps, room: Room, matrixClient: MatrixClient): ReactElement | null {
|
||||
const sender = room.getMember(matrixClient.getSafeUserId());
|
||||
|
||||
return props.showLocationButton && sender ? (
|
||||
<LocationButton
|
||||
key="location"
|
||||
roomId={roomId}
|
||||
roomId={room.roomId}
|
||||
relation={props.relation}
|
||||
sender={sender}
|
||||
menuPosition={props.menuPosition}
|
||||
|
|
|
@ -151,7 +151,7 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
|
|||
const result = await MatrixClientPeg.get().lookupThreePid(
|
||||
"email",
|
||||
this.props.invitedEmail,
|
||||
identityAccessToken,
|
||||
identityAccessToken!,
|
||||
);
|
||||
this.setState({ invitedEmailMxid: result.mxid });
|
||||
} catch (err) {
|
||||
|
@ -243,8 +243,8 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
|
|||
if (!inviteEvent) {
|
||||
return null;
|
||||
}
|
||||
const inviterUserId = inviteEvent.events.member.getSender();
|
||||
return room.currentState.getMember(inviterUserId);
|
||||
const inviterUserId = inviteEvent.events.member?.getSender();
|
||||
return inviterUserId ? room.currentState.getMember(inviterUserId) : null;
|
||||
}
|
||||
|
||||
private isDMInvite(): boolean {
|
||||
|
@ -252,8 +252,8 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
|
|||
if (!myMember) {
|
||||
return false;
|
||||
}
|
||||
const memberContent = myMember.events.member.getContent();
|
||||
return memberContent.membership === "invite" && memberContent.is_direct;
|
||||
const memberContent = myMember.events.member?.getContent();
|
||||
return memberContent?.membership === "invite" && memberContent.is_direct;
|
||||
}
|
||||
|
||||
private makeScreenAfterLogin(): { screen: string; params: Record<string, any> } {
|
||||
|
|
|
@ -64,7 +64,7 @@ export default class SearchResultTile extends React.Component<IProps> {
|
|||
const eventId = resultEvent.getId();
|
||||
|
||||
const ts1 = resultEvent.getTs();
|
||||
const ret = [<DateSeparator key={ts1 + "-search"} roomId={resultEvent.getRoomId()} ts={ts1} />];
|
||||
const ret = [<DateSeparator key={ts1 + "-search"} roomId={resultEvent.getRoomId()!} ts={ts1} />];
|
||||
const layout = SettingsStore.getValue("layout");
|
||||
const isTwelveHour = SettingsStore.getValue("showTwelveHourTimestamps");
|
||||
const alwaysShowTimestamps = SettingsStore.getValue("alwaysShowTimestamps");
|
||||
|
|
|
@ -372,7 +372,10 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
return false;
|
||||
}
|
||||
this.currentlyComposedEditorState = this.model.serializeParts();
|
||||
} else if (this.sendHistoryManager.currentIndex + delta === this.sendHistoryManager.history.length) {
|
||||
} else if (
|
||||
this.currentlyComposedEditorState &&
|
||||
this.sendHistoryManager.currentIndex + delta === this.sendHistoryManager.history.length
|
||||
) {
|
||||
// True when we return to the message being composed currently
|
||||
this.model.reset(this.currentlyComposedEditorState);
|
||||
this.sendHistoryManager.currentIndex = this.sendHistoryManager.history.length;
|
||||
|
@ -393,6 +396,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
|
||||
private sendQuickReaction(): void {
|
||||
const timeline = this.context.liveTimeline;
|
||||
if (!timeline) return;
|
||||
const events = timeline.getEvents();
|
||||
const reaction = this.model.parts[1].text;
|
||||
for (let i = events.length - 1; i >= 0; i--) {
|
||||
|
@ -443,8 +447,8 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
isReply: !!this.props.replyToEvent,
|
||||
inThread: this.props.relation?.rel_type === THREAD_RELATION_TYPE.name,
|
||||
};
|
||||
if (posthogEvent.inThread) {
|
||||
const threadRoot = this.props.room.findEventById(this.props.relation.event_id);
|
||||
if (posthogEvent.inThread && this.props.relation!.event_id) {
|
||||
const threadRoot = this.props.room.findEventById(this.props.relation!.event_id);
|
||||
posthogEvent.startsThread = threadRoot?.getThread()?.events.length === 1;
|
||||
}
|
||||
PosthogAnalytics.instance.trackEvent<ComposerEvent>(posthogEvent);
|
||||
|
@ -480,7 +484,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
return; // errored
|
||||
}
|
||||
|
||||
if (cmd.category === CommandCategories.messages || cmd.category === CommandCategories.effects) {
|
||||
if (content && [CommandCategories.messages, CommandCategories.effects].includes(cmd.category)) {
|
||||
// Attach any mentions which might be contained in the command content.
|
||||
attachMentions(this.props.mxClient.getSafeUserId(), content, model, replyToEvent);
|
||||
attachRelation(content, this.props.relation);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue