fix: keyboard handler memoization

This commit is contained in:
kirillzyusko
2024-11-25 13:33:09 +01:00
parent b9406aa011
commit 7711c56598
2 changed files with 33 additions and 27 deletions
+5 -2
View File
@@ -214,12 +214,15 @@ export const ScrollableInner = React.forwardRef<ScrollView, DialogInnerProps>(
} }
}) })
useKeyboardHandler({ useKeyboardHandler(
{
onEnd: e => { onEnd: e => {
'worklet' 'worklet'
runOnJS(setKeyboardHeight)(e.height) runOnJS(setKeyboardHeight)(e.height)
}, },
}) },
[],
)
const basePading = const basePading =
(isIOS ? 30 : 50) + (isIOS ? keyboardHeight / 4 : keyboardHeight) (isIOS ? 30 : 50) + (isIOS ? keyboardHeight / 4 : keyboardHeight)
@@ -250,7 +250,8 @@ export function MessagesList({
// We use this value to keep track of when we want to disable the animation. // We use this value to keep track of when we want to disable the animation.
const layoutScrollWithoutAnimation = useSharedValue(false) const layoutScrollWithoutAnimation = useSharedValue(false)
useKeyboardHandler({ useKeyboardHandler(
{
onStart: e => { onStart: e => {
'worklet' 'worklet'
// Immediate updates - like opening the emoji picker - will have a duration of zero. In those cases, we should // Immediate updates - like opening the emoji picker - will have a duration of zero. In those cases, we should
@@ -273,7 +274,9 @@ export function MessagesList({
'worklet' 'worklet'
keyboardIsOpening.set(false) keyboardIsOpening.set(false)
}, },
}) },
[],
)
const animatedListStyle = useAnimatedStyle(() => ({ const animatedListStyle = useAnimatedStyle(() => ({
marginBottom: marginBottom: