Avoid calling prepareToEncrypt onKeyDown (#10828)
* Avoid calling prepareToEncrypt onKeyDown * Iterate
This commit is contained in:
parent
b3fd9377d6
commit
08368860f4
3 changed files with 38 additions and 12 deletions
|
@ -107,7 +107,7 @@ interface IProps {
|
|||
initialCaret?: DocumentOffset;
|
||||
disabled?: boolean;
|
||||
|
||||
onChange?(): void;
|
||||
onChange?(selection: Caret, inputType?: string, diff?: IDiff): void;
|
||||
onPaste?(event: ClipboardEvent<HTMLDivElement>, model: EditorModel): boolean;
|
||||
}
|
||||
|
||||
|
@ -278,9 +278,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
|
|||
isTyping,
|
||||
);
|
||||
|
||||
if (this.props.onChange) {
|
||||
this.props.onChange();
|
||||
}
|
||||
this.props.onChange?.(selection, inputType, diff);
|
||||
};
|
||||
|
||||
private showPlaceholder(): void {
|
||||
|
|
|
@ -59,6 +59,8 @@ import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
|
|||
import { PosthogAnalytics } from "../../../PosthogAnalytics";
|
||||
import { addReplyToMessageContent } from "../../../utils/Reply";
|
||||
import { doMaybeLocalRoomAction } from "../../../utils/local-room";
|
||||
import { Caret } from "../../../editor/caret";
|
||||
import { IDiff } from "../../../editor/diff";
|
||||
|
||||
/**
|
||||
* Build the mentions information based on the editor model (and any related events):
|
||||
|
@ -353,11 +355,6 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
context: this.context.timelineRenderingType,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
if (this.prepareToEncrypt) {
|
||||
// This needs to be last!
|
||||
this.prepareToEncrypt();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -689,8 +686,13 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
return false;
|
||||
};
|
||||
|
||||
private onChange = (): void => {
|
||||
if (this.props.onChange) this.props.onChange(this.model);
|
||||
private onChange = (selection: Caret, inputType?: string, diff?: IDiff): void => {
|
||||
// We call this in here rather than onKeyDown as that would trip it on global shortcuts e.g. Ctrl-k also
|
||||
if (!!diff) {
|
||||
this.prepareToEncrypt?.();
|
||||
}
|
||||
|
||||
this.props.onChange?.(this.model);
|
||||
};
|
||||
|
||||
private focusComposer = (): void => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue