Skip to content

Commit 299cef0

Browse files
committed
fix(mobile): preserve thread head while positioning replies
Signed-off-by: Tom Brow <[email protected]>
1 parent 15f0998 commit 299cef0

4 files changed

Lines changed: 297 additions & 243 deletions

File tree

‎mobile/lib/features/channels/initial_thread_tail_settle.dart‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ class InitialThreadTailSettle {
4141
if (_isComplete) return;
4242

4343
final generation = ++_generation;
44-
if (targetIndex == null) {
45-
_isComplete = true;
46-
onSettled();
47-
return;
48-
}
49-
5044
WidgetsBinding.instance.addPostFrameCallback((_) {
5145
if (!context.mounted || generation != _generation) return;
46+
// Report readiness after build, including empty threads. A synchronous
47+
// hook update can otherwise leave the just-built visibility value stale.
48+
if (targetIndex == null) {
49+
_isComplete = true;
50+
onSettled();
51+
return;
52+
}
5253

5354
// Let events received during hydration rebuild the list before committing
5455
// the target. That rebuild schedules a new generation at the current tail.

‎mobile/lib/features/channels/thread_detail_page.dart‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,11 @@ class ThreadDetailPage extends HookConsumerWidget {
284284
? settledImeLift
285285
: 0);
286286
final navigationBottomInset = composerDockHeight.value + settledImeLift;
287-
// Keep the route snapshot usable while the relay query is pending. Once
288-
// authoritative replies arrive, suppress only the frame(s) used to place
289-
// the hydrated target. An ordinary empty thread has no target to place:
290-
// keep its original message visible across hydration.
287+
// Keep the route snapshot usable during loading. While the hydrated list
288+
// settles, the message-list view keeps the original message visible and
289+
// reveals the positioned list in one frame, for empty and populated threads.
291290
final threadViewportVisible =
292-
!relayRepliesAvailable ||
293-
(initialMessageId == null && replies.isEmpty) ||
294-
initialViewportReady.value;
291+
!relayRepliesAvailable || initialViewportReady.value;
295292

296293
// Item 0 is the thread head; reply `i` lives at `i + 1`.
297294
const headIndex = 0;

0 commit comments

Comments
 (0)