Skip to content

Commit 7ade40f

Browse files
committed
msglist: In single-conversation view, make recipient headers not tappable.
Fixes: #1171
1 parent 7e3d136 commit 7ade40f

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

lib/widgets/message_list.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,13 @@ class StreamMessageRecipientHeader extends StatelessWidget {
11081108
]));
11091109

11101110
return GestureDetector(
1111-
onTap: () => Navigator.push(context,
1111+
// When already in a topic narrow, disable tap interaction that would just
1112+
// push a MessageListPage for the same topic narrow.
1113+
// TODO(#1039) simplify by removing topic-narrow condition if we remove
1114+
// recipient headers in topic narrows
1115+
onTap: (narrow is TopicNarrow)
1116+
? null
1117+
: () => Navigator.push(context,
11121118
MessageListPage.buildRoute(context: context,
11131119
narrow: TopicNarrow.ofMessage(message))),
11141120
onLongPress: () => showTopicActionSheet(context,
@@ -1157,7 +1163,13 @@ class DmRecipientHeader extends StatelessWidget {
11571163
final messageListTheme = MessageListTheme.of(context);
11581164

11591165
return GestureDetector(
1160-
onTap: () => Navigator.push(context,
1166+
// When already in a DM narrow, disable tap interaction that would just
1167+
// push a MessageListPage for the same DM narrow.
1168+
// TODO(#1244) simplify by removing DM-narrow condition if we remove
1169+
// recipient headers in DM narrows
1170+
onTap: (narrow is DmNarrow)
1171+
? null
1172+
: () => Navigator.push(context,
11611173
MessageListPage.buildRoute(context: context,
11621174
narrow: DmNarrow.ofMessage(message, selfUserId: store.selfUserId))),
11631175
child: ColoredBox(

test/widgets/message_list_test.dart

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,53 @@ void main() {
923923
await tester.pump();
924924
tester.widget(find.text('new stream name'));
925925
});
926+
927+
testWidgets('navigates to TopicNarrow on tapping topic in ChannelNarrow', (tester) async {
928+
final pushedRoutes = <Route<void>>[];
929+
final navObserver = TestNavigatorObserver()
930+
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
931+
final channel = eg.stream();
932+
await setupMessageListPage(tester,
933+
narrow: ChannelNarrow(channel.streamId),
934+
messages: [eg.streamMessage(stream: channel, topic: 'topic name')],
935+
streams: [channel],
936+
navObservers: [navObserver]);
937+
938+
assert(pushedRoutes.length == 1);
939+
pushedRoutes.clear();
940+
941+
connection.prepare(json: eg.newestGetMessagesResult(
942+
foundOldest: true, messages: [message]).toJson());
943+
await tester.tap(find.descendant(
944+
of: find.byType(StreamMessageRecipientHeader),
945+
matching: find.text('topic name')));
946+
await tester.pumpAndSettle();
947+
check(pushedRoutes).single
948+
.isA<WidgetRoute>()
949+
.page.isA<MessageListPage>()
950+
.initNarrow.equals(TopicNarrow(channel.streamId, TopicName('topic name')));
951+
});
952+
953+
testWidgets('does not navigate on tapping topic in TopicNarrow', (tester) async {
954+
final pushedRoutes = <Route<void>>[];
955+
final navObserver = TestNavigatorObserver()
956+
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
957+
final channel = eg.stream();
958+
await setupMessageListPage(tester,
959+
narrow: TopicNarrow(channel.streamId, TopicName('topic name')),
960+
navObservers: [navObserver],
961+
streams: [channel],
962+
messages: [eg.streamMessage(stream: channel, topic: 'topic name')]);
963+
964+
assert(pushedRoutes.length == 1);
965+
pushedRoutes.clear();
966+
967+
await tester.tap(find.descendant(
968+
of: find.byType(StreamMessageRecipientHeader),
969+
matching: find.text('topic name')));
970+
await tester.pump();
971+
check(pushedRoutes).isEmpty();
972+
});
926973
});
927974

928975
group('DmRecipientHeader', () {

0 commit comments

Comments
 (0)