fix issue where entered message isn't immediately visible

This commit is contained in:
Red Adaya 2024-05-01 07:40:11 +08:00
parent dbc91d8a4e
commit 8b8b7ea2b6
2 changed files with 4 additions and 33 deletions

View File

@ -44,8 +44,8 @@
}
.chat-msg {
margin-top: calc(var(--termpad) * 2);
margin-bottom: calc(var(--termpad) * 2);
padding-top: calc(var(--termpad) * 2);
padding-bottom: calc(var(--termpad) * 2);
display: flex;
.chat-msg-header {

View File

@ -60,12 +60,12 @@ class ChatContent extends React.Component<{}, {}> {
osInstance: OverlayScrollbars = null;
componentDidUpdate() {
console.log("triggered");
if (this.containerRef?.current && this.osInstance) {
const { overflowAmount } = this.osInstance.state();
const { viewport } = this.osInstance.elements();
viewport.scrollTo({
behavior: "auto",
top: overflowAmount.y,
top: this.chatWindowRef.current.scrollHeight,
});
}
}
@ -87,35 +87,6 @@ class ChatContent extends React.Component<{}, {}> {
});
}
submitChatMessage(messageStr: string) {
const curLine = GlobalModel.inputModel.getCurLine();
const prtn = GlobalModel.submitChatInfoCommand(messageStr, curLine, false);
prtn.then((rtn) => {
if (!rtn.success) {
console.log("submit chat command error: " + rtn.error);
}
}).catch((_) => {});
}
getLinePos(elem: any): { numLines: number; linePos: number } {
const numLines = elem.value.split("\n").length;
const linePos = elem.value.substr(0, elem.selectionStart).split("\n").length;
return { numLines, linePos };
}
onTextAreaFocused(e: any) {
console.log("focused=====");
mobx.action(() => {
GlobalModel.inputModel.setAuxViewFocus(true);
})();
}
onTextAreaBlur(e: any) {
mobx.action(() => {
GlobalModel.inputModel.setAuxViewFocus(false);
})();
}
renderError(err: string): any {
return <div className="chat-msg-error">{err}</div>;
}