Skip to content

Commit 24aef3e

Browse files
committed
fix(mobile): keep optimistic threads tappable
Signed-off-by: Tom Brow <[email protected]>
1 parent 110e988 commit 24aef3e

3 files changed

Lines changed: 54 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import '../profile/user_profile_sheet.dart';
7676
import 'small_avatar.dart';
7777
import 'sticky_date_header.dart';
7878
import 'thread_detail_page.dart';
79+
import 'thread_replies_provider.dart';
7980
import 'timeline_message.dart';
8081

8182
part 'channel_detail_page/message_list.dart';

‎mobile/lib/features/channels/channel_detail_page/message_bubble.dart‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ class _MessageBubble extends HookConsumerWidget {
3030
@override
3131
Widget build(BuildContext context, WidgetRef ref) {
3232
final messageSnapshotKey = useMemoized(GlobalKey.new, const []);
33+
final hasLocalReplies = ref.watch(
34+
threadLocalRepliesProvider(
35+
ThreadRepliesArgs(
36+
channelId: currentChannelId,
37+
rootId: message.rootId ?? message.id,
38+
),
39+
).select(
40+
(replies) => replies.any((reply) {
41+
final thread = reply.threadReference;
42+
return thread.parentId == message.id || thread.rootId == message.id;
43+
}),
44+
),
45+
);
3346
// Watch only this user's profile to avoid rebuilding on unrelated cache changes.
3447
final pk = message.pubkey.toLowerCase();
3548
final profile =
@@ -119,7 +132,7 @@ class _MessageBubble extends HookConsumerWidget {
119132
snapshotKey: messageSnapshotKey,
120133
// Tap opens existing threads; long-press can start a new one.
121134
// MessageContent handles mention, channel-link, and media taps.
122-
onTap: !hasReplies || allMessages == null
135+
onTap: (!hasReplies && !hasLocalReplies) || allMessages == null
123136
? null
124137
: () => Navigator.of(context).push(
125138
MaterialPageRoute<void>(

‎mobile/test/features/channels/channel_detail_page_test.dart‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10265,6 +10265,45 @@ void main() {
1026510265
});
1026610266

1026710267
group('Message row thread navigation', () {
10268+
testWidgets('a local reply makes its thread immediately tappable', (
10269+
tester,
10270+
) async {
10271+
final root = _textMsg(
10272+
id: 'local-root',
10273+
pubkey: 'alice',
10274+
content: 'Start a local thread',
10275+
);
10276+
final notifier = _FakeMessagesNotifier([root]);
10277+
await tester.pumpWidget(
10278+
_buildTestable(
10279+
messages: [root],
10280+
messagesNotifier: notifier,
10281+
threadReplies: const {'local-root': []},
10282+
),
10283+
);
10284+
await tester.pumpAndSettle();
10285+
await tester.tap(findRichText('Start a local thread'));
10286+
await tester.pumpAndSettle();
10287+
expect(find.byType(ThreadDetailPage), findsNothing);
10288+
10289+
notifier.addLocalMessage(
10290+
_textMsg(
10291+
id: 'local-reply',
10292+
pubkey: 'self',
10293+
content: 'Waiting for relay echo',
10294+
createdAt: 1100,
10295+
extraTags: const [
10296+
['e', 'local-root', '', 'reply'],
10297+
],
10298+
),
10299+
);
10300+
await tester.pumpAndSettle();
10301+
await tester.tap(findRichText('Start a local thread'));
10302+
await tester.pumpAndSettle();
10303+
expect(find.byType(ThreadDetailPage), findsOneWidget);
10304+
expect(findRichText('Waiting for relay echo'), findsOneWidget);
10305+
});
10306+
1026810307
testWidgets('tapping a message with unloaded replies opens its thread', (
1026910308
tester,
1027010309
) async {

0 commit comments

Comments
 (0)