my fork of the bluesky client

fix: keyboard handler memoization (#6719)

* fix: keyboard handler memoization

* fix: return missing dependency

authored by

Kirill Zyusko and committed by
GitHub
723bbfc5 5164ca62

+33 -27
+8 -5
src/components/Dialog/index.tsx
··· 214 214 } 215 215 }) 216 216 217 - useKeyboardHandler({ 218 - onEnd: e => { 219 - 'worklet' 220 - runOnJS(setKeyboardHeight)(e.height) 217 + useKeyboardHandler( 218 + { 219 + onEnd: e => { 220 + 'worklet' 221 + runOnJS(setKeyboardHeight)(e.height) 222 + }, 221 223 }, 222 - }) 224 + [], 225 + ) 223 226 224 227 const basePading = 225 228 (isIOS ? 30 : 50) + (isIOS ? keyboardHeight / 4 : keyboardHeight)
+25 -22
src/screens/Messages/components/MessagesList.tsx
··· 250 250 // We use this value to keep track of when we want to disable the animation. 251 251 const layoutScrollWithoutAnimation = useSharedValue(false) 252 252 253 - useKeyboardHandler({ 254 - onStart: e => { 255 - 'worklet' 256 - // Immediate updates - like opening the emoji picker - will have a duration of zero. In those cases, we should 257 - // just update the height here instead of having the `onMove` event do it (that event will not fire!) 258 - if (e.duration === 0) { 259 - layoutScrollWithoutAnimation.set(true) 253 + useKeyboardHandler( 254 + { 255 + onStart: e => { 256 + 'worklet' 257 + // Immediate updates - like opening the emoji picker - will have a duration of zero. In those cases, we should 258 + // just update the height here instead of having the `onMove` event do it (that event will not fire!) 259 + if (e.duration === 0) { 260 + layoutScrollWithoutAnimation.set(true) 261 + keyboardHeight.set(e.height) 262 + } else { 263 + keyboardIsOpening.set(true) 264 + } 265 + }, 266 + onMove: e => { 267 + 'worklet' 260 268 keyboardHeight.set(e.height) 261 - } else { 262 - keyboardIsOpening.set(true) 263 - } 269 + if (e.height > bottomOffset) { 270 + scrollTo(flatListRef, 0, 1e7, false) 271 + } 272 + }, 273 + onEnd: () => { 274 + 'worklet' 275 + keyboardIsOpening.set(false) 276 + }, 264 277 }, 265 - onMove: e => { 266 - 'worklet' 267 - keyboardHeight.set(e.height) 268 - if (e.height > bottomOffset) { 269 - scrollTo(flatListRef, 0, 1e7, false) 270 - } 271 - }, 272 - onEnd: () => { 273 - 'worklet' 274 - keyboardIsOpening.set(false) 275 - }, 276 - }) 278 + [bottomOffset], 279 + ) 277 280 278 281 const animatedListStyle = useAnimatedStyle(() => ({ 279 282 marginBottom: