Fixes for thread composer on Android (#6045)

* Extract function to read contentHeight later

* Remove autoscroll to bottom

We're going to implement this in the UI layer instead.

* Remove worklet from non-worklets to avoid confusion

* Rename and invert hasScrolled* variables

Their naming was too ambiguous (they used to represent "has scrolled _away_ from X"). I inverted them and clarified the naming. No functional changes.

* This should not be necessary

It's already called not just from UI thread. And it only sets shared values, which can be done from either thread.

* Make hasScrolledTo* derived values

It wasn't always correct to derive them manually because reading from .value is stale on JS thread. We could fix that by using the local variables but it makes more conceptualy sense to treat these as derived anyway.

* Reimplement autoscroll-to-bottom in UI layer

Doing it here ensures we also do it when you add an image at the end of the thread. Otherwise it's very confusing where it went.

* Use fancy ScrollView

This seems to fix ScrollView getting stuck after inserting images at the thread end on Android.

* More aggressive scroll-to-bottom

* "Fix" cursor getting stuck on Android

* Revert "Use fancy ScrollView"

This reverts commit 04e34a54e3b75f8a77de5062bff5fe6e76420bbb.
This commit is contained in:
dan
2024-11-01 03:47:53 +00:00
committed by GitHub
parent 7a08d61d88
commit 21b82fa19c
2 changed files with 52 additions and 37 deletions
-4
View File
@@ -87,7 +87,6 @@ export type ComposerState = {
thread: ThreadDraft
activePostIndex: number
mutableNeedsFocusActive: boolean
mutableNeedsScrollToBottom: boolean
}
export type ComposerAction =
@@ -157,7 +156,6 @@ export function composerReducer(
}
case 'add_post': {
const activePostIndex = state.activePostIndex
const isAtTheEnd = activePostIndex === state.thread.posts.length - 1
const nextPosts = [...state.thread.posts]
nextPosts.splice(activePostIndex + 1, 0, {
id: nanoid(),
@@ -172,7 +170,6 @@ export function composerReducer(
})
return {
...state,
mutableNeedsScrollToBottom: isAtTheEnd,
thread: {
...state.thread,
posts: nextPosts,
@@ -514,7 +511,6 @@ export function createComposerState({
return {
activePostIndex: 0,
mutableNeedsFocusActive: false,
mutableNeedsScrollToBottom: false,
thread: {
posts: [
{