From 8b8b7ea2b62e2dbdd8b2ca17f13d306a5b1a0daf Mon Sep 17 00:00:00 2001 From: Red Adaya Date: Wed, 1 May 2024 07:40:11 +0800 Subject: [PATCH] fix issue where entered message isn't immediately visible --- src/app/sidebar/aichat.less | 4 ++-- src/app/sidebar/aichat.tsx | 33 ++------------------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/src/app/sidebar/aichat.less b/src/app/sidebar/aichat.less index b39faf627..87b346a9f 100644 --- a/src/app/sidebar/aichat.less +++ b/src/app/sidebar/aichat.less @@ -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 { diff --git a/src/app/sidebar/aichat.tsx b/src/app/sidebar/aichat.tsx index ac5fb8664..de4ab1bed 100644 --- a/src/app/sidebar/aichat.tsx +++ b/src/app/sidebar/aichat.tsx @@ -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
{err}
; }