Skip to content

Commit

Permalink
fix: continue response setting incorrect text box height on release b…
Browse files Browse the repository at this point in the history
…uilds
  • Loading branch information
Vali-98 committed Oct 4, 2024
1 parent fb7f4c6 commit 6836153
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/components/ChatMenu/ChatWindow/ChatText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ChatText: React.FC<ChatTextProps> = ({ nowGenerating, id }) => {
}).start()
)
}

const handleContentSizeChange = (event: LayoutChangeEvent) => {
const newHeight = event.nativeEvent.layout.height
const oveflowPadding = 12
Expand Down
9 changes: 4 additions & 5 deletions app/components/ChatMenu/ChatWindow/ChatTextLast.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useInference } from '@constants/Chat'
import { Chats, Style, MarkdownStyle } from '@globals'
import React, { useEffect, useRef } from 'react'
import { StyleSheet, Animated, Easing, LayoutChangeEvent } from 'react-native'
import { StyleSheet, Easing, LayoutChangeEvent, Animated } from 'react-native'
//@ts-expect-error
import Markdown from 'react-native-markdown-package'
//@ts-expect-error
Expand All @@ -14,9 +14,6 @@ type ChatTextProps = {
}

const ChatTextLast: React.FC<ChatTextProps> = ({ nowGenerating, id }) => {
const animatedHeight = useRef(new Animated.Value(-1)).current
const height = useRef(-1)

const { mes, swipeId } = Chats.useChat((state) => ({
mes:
state?.data?.messages?.[id]?.swipes?.[state?.data?.messages?.[id].swipe_id ?? -1]
Expand All @@ -35,6 +32,8 @@ const ChatTextLast: React.FC<ChatTextProps> = ({ nowGenerating, id }) => {
}))
)

const animatedHeight = useRef(new Animated.Value(-1)).current
const height = useRef(-1)
const handleAnimateHeight = (newheight: number) => {
animatedHeight.stopAnimation(() =>
Animated.timing(animatedHeight, {
Expand Down Expand Up @@ -65,7 +64,7 @@ const ChatTextLast: React.FC<ChatTextProps> = ({ nowGenerating, id }) => {
useEffect(() => {
if (!nowGenerating && height.current !== -1) {
handleAnimateHeight(height.current)
} else if (nowGenerating && mes) {
} else if (nowGenerating && !mes) {
// NOTE: this assumes that mes is empty due to a swipe and may break, but unlikely
height.current = 0
handleAnimateHeight(height.current)
Expand Down

0 comments on commit 6836153

Please sign in to comment.