keep the original 50ms one as well
This commit is contained in:
@@ -157,15 +157,29 @@ export const ComposePost = observer(function ComposePost({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isAndroid) return
|
if (!isAndroid) return
|
||||||
let numTries = 20
|
|
||||||
const id = setInterval(() => {
|
// optimistic first try to focus keyboard
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
textInput.current?.focus()
|
||||||
|
}, 50)
|
||||||
|
|
||||||
|
// however, sometimes that fires too soon, and the keyboard doesn't show
|
||||||
|
// so we try a few more times
|
||||||
|
let numTries = 5
|
||||||
|
const interval = setInterval(() => {
|
||||||
if (Keyboard.isVisible() || numTries-- <= 0) {
|
if (Keyboard.isVisible() || numTries-- <= 0) {
|
||||||
clearInterval(id)
|
clearInterval(interval)
|
||||||
} else {
|
} else {
|
||||||
|
// focusing doesn't open keyboard if it's already focused
|
||||||
|
textInput.current?.blur()
|
||||||
textInput.current?.focus()
|
textInput.current?.focus()
|
||||||
}
|
}
|
||||||
}, 50)
|
}, 250)
|
||||||
return () => clearInterval(id)
|
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timeout)
|
||||||
|
clearInterval(interval)
|
||||||
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const gallery = useMemo(
|
const gallery = useMemo(
|
||||||
|
|||||||
Reference in New Issue
Block a user