Skip to content

Commit

Permalink
msglist: In single-conversation view, make recipient headers not tapp…
Browse files Browse the repository at this point in the history
…able.

Fixes: zulip#1171
  • Loading branch information
lakshya1goel committed Jan 24, 2025
1 parent 7e3d136 commit 7ade40f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,13 @@ class StreamMessageRecipientHeader extends StatelessWidget {
]));

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

return GestureDetector(
onTap: () => Navigator.push(context,
// When already in a DM narrow, disable tap interaction that would just
// push a MessageListPage for the same DM narrow.
// TODO(#1244) simplify by removing DM-narrow condition if we remove
// recipient headers in DM narrows
onTap: (narrow is DmNarrow)
? null
: () => Navigator.push(context,
MessageListPage.buildRoute(context: context,
narrow: DmNarrow.ofMessage(message, selfUserId: store.selfUserId))),
child: ColoredBox(
Expand Down
47 changes: 47 additions & 0 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,53 @@ void main() {
await tester.pump();
tester.widget(find.text('new stream name'));
});

testWidgets('navigates to TopicNarrow on tapping topic in ChannelNarrow', (tester) async {
final pushedRoutes = <Route<void>>[];
final navObserver = TestNavigatorObserver()
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
final channel = eg.stream();
await setupMessageListPage(tester,
narrow: ChannelNarrow(channel.streamId),
messages: [eg.streamMessage(stream: channel, topic: 'topic name')],
streams: [channel],
navObservers: [navObserver]);

assert(pushedRoutes.length == 1);
pushedRoutes.clear();

connection.prepare(json: eg.newestGetMessagesResult(
foundOldest: true, messages: [message]).toJson());
await tester.tap(find.descendant(
of: find.byType(StreamMessageRecipientHeader),
matching: find.text('topic name')));
await tester.pumpAndSettle();
check(pushedRoutes).single
.isA<WidgetRoute>()
.page.isA<MessageListPage>()
.initNarrow.equals(TopicNarrow(channel.streamId, TopicName('topic name')));
});

testWidgets('does not navigate on tapping topic in TopicNarrow', (tester) async {
final pushedRoutes = <Route<void>>[];
final navObserver = TestNavigatorObserver()
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
final channel = eg.stream();
await setupMessageListPage(tester,
narrow: TopicNarrow(channel.streamId, TopicName('topic name')),
navObservers: [navObserver],
streams: [channel],
messages: [eg.streamMessage(stream: channel, topic: 'topic name')]);

assert(pushedRoutes.length == 1);
pushedRoutes.clear();

await tester.tap(find.descendant(
of: find.byType(StreamMessageRecipientHeader),
matching: find.text('topic name')));
await tester.pump();
check(pushedRoutes).isEmpty();
});
});

group('DmRecipientHeader', () {
Expand Down

0 comments on commit 7ade40f

Please sign in to comment.