Conform more code to strict null checking (#10153)
* Conform more code to strict null checking * Conform more code to strict null checking * Iterate * Iterate
This commit is contained in:
parent
a4ff959aa1
commit
145a5a8a8d
89 changed files with 520 additions and 551 deletions
|
@ -73,7 +73,7 @@ export function attachRelation(content: IContent, relation?: IEventRelation): vo
|
|||
// exported for tests
|
||||
export function createMessageContent(
|
||||
model: EditorModel,
|
||||
replyToEvent: MatrixEvent,
|
||||
replyToEvent: MatrixEvent | undefined,
|
||||
relation: IEventRelation | undefined,
|
||||
permalinkCreator: RoomPermalinkCreator,
|
||||
includeReplyLegacyFallback = true,
|
||||
|
@ -148,8 +148,8 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
|
||||
private readonly prepareToEncrypt?: DebouncedFunc<() => void>;
|
||||
private readonly editorRef = createRef<BasicMessageComposer>();
|
||||
private model: EditorModel = null;
|
||||
private currentlyComposedEditorState: SerializedPart[] = null;
|
||||
private model: EditorModel;
|
||||
private currentlyComposedEditorState: SerializedPart[] | null = null;
|
||||
private dispatcherRef: string;
|
||||
private sendHistoryManager: SendHistoryManager;
|
||||
|
||||
|
@ -299,7 +299,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
const lastMessage = events[i];
|
||||
const userId = MatrixClientPeg.get().getUserId();
|
||||
const messageReactions = this.props.room.relations.getChildEventsForEvent(
|
||||
lastMessage.getId(),
|
||||
lastMessage.getId()!,
|
||||
RelationType.Annotation,
|
||||
EventType.Reaction,
|
||||
);
|
||||
|
@ -314,7 +314,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
shouldReact = !myReactionKeys.includes(reaction);
|
||||
}
|
||||
if (shouldReact) {
|
||||
MatrixClientPeg.get().sendEvent(lastMessage.getRoomId(), EventType.Reaction, {
|
||||
MatrixClientPeg.get().sendEvent(lastMessage.getRoomId()!, EventType.Reaction, {
|
||||
"m.relates_to": {
|
||||
rel_type: RelationType.Annotation,
|
||||
event_id: lastMessage.getId(),
|
||||
|
@ -359,7 +359,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
|
||||
const replyToEvent = this.props.replyToEvent;
|
||||
let shouldSend = true;
|
||||
let content: IContent;
|
||||
let content: IContent | null = null;
|
||||
|
||||
if (!containsEmote(model) && isSlashCommand(this.model)) {
|
||||
const [cmd, args, commandText] = getSlashCommand(this.model);
|
||||
|
@ -481,7 +481,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
localStorage.removeItem(this.editorStateKey);
|
||||
}
|
||||
|
||||
private restoreStoredEditorState(partCreator: PartCreator): Part[] {
|
||||
private restoreStoredEditorState(partCreator: PartCreator): Part[] | null {
|
||||
const replyingToThread = this.props.relation?.key === THREAD_RELATION_TYPE.name;
|
||||
if (replyingToThread) {
|
||||
return null;
|
||||
|
@ -504,6 +504,8 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// should save state when editor has contents or reply is open
|
||||
|
@ -563,6 +565,8 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
);
|
||||
return true; // to skip internal onPaste handler
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
private onChange = (): void => {
|
||||
|
@ -575,7 +579,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
|
||||
public render(): React.ReactNode {
|
||||
const threadId =
|
||||
this.props.relation?.rel_type === THREAD_RELATION_TYPE.name ? this.props.relation.event_id : null;
|
||||
this.props.relation?.rel_type === THREAD_RELATION_TYPE.name ? this.props.relation.event_id : undefined;
|
||||
return (
|
||||
<div className="mx_SendMessageComposer" onClick={this.focusComposer} onKeyDown={this.onKeyDown}>
|
||||
<BasicMessageComposer
|
||||
|
|
|
@ -90,7 +90,7 @@ export default class DevicesPanelEntry extends React.Component<IProps, IState> {
|
|||
Modal.createDialog(
|
||||
LogoutDialog,
|
||||
/* props= */ {},
|
||||
/* className= */ null,
|
||||
/* className= */ undefined,
|
||||
/* isPriority= */ false,
|
||||
/* isStatic= */ true,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue