@@ -21,13 +21,16 @@ type Props = Pick<ChatReply, 'messages' | 'input'> & {
|
||||
}
|
||||
|
||||
export const ChatChunk = (props: Props) => {
|
||||
let inputRef: HTMLDivElement | undefined
|
||||
const [displayedMessageIndex, setDisplayedMessageIndex] = createSignal(0)
|
||||
|
||||
onMount(() => {
|
||||
if (props.messages.length === 0) {
|
||||
props.onAllBubblesDisplayed()
|
||||
}
|
||||
props.onScrollToBottom()
|
||||
props.onScrollToBottom(
|
||||
inputRef?.offsetTop ? inputRef?.offsetTop - 50 : undefined
|
||||
)
|
||||
})
|
||||
|
||||
const displayNextMessage = async (bubbleOffsetTop?: number) => {
|
||||
@@ -84,6 +87,7 @@ export const ChatChunk = (props: Props) => {
|
||||
</Show>
|
||||
{props.input && displayedMessageIndex() === props.messages.length && (
|
||||
<InputChatBlock
|
||||
ref={inputRef}
|
||||
block={props.input}
|
||||
inputIndex={props.inputIndex}
|
||||
onSubmit={props.onSubmit}
|
||||
|
||||
Reference in New Issue
Block a user