Skip to content

Commit

Permalink
msglist: Display realmEmptyTopicDisplayName where empty topic appears
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Feb 21, 2025
1 parent 95e0e06 commit f3f9712
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,11 @@ class MessageListAppBarTitle extends StatelessWidget {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(topic.displayName, style: const TextStyle(
// ignore: dead_null_aware_expression // null topic names soon to be enabled
Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle(
fontSize: 13,
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
fontStyle: topic.displayName == null ? FontStyle.italic : null,
).merge(weightVariableTextStyle(context)))),
if (icon != null)
Padding(
Expand Down Expand Up @@ -1120,11 +1123,15 @@ class StreamMessageRecipientHeader extends StatelessWidget {
child: Row(
children: [
Flexible(
child: Text(topic.displayName,
// ignore: dead_null_aware_expression // null topic names soon to be enabled
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
// TODO: Give a way to see the whole topic (maybe a
// long-press interaction?)
overflow: TextOverflow.ellipsis,
style: recipientHeaderTextStyle(context))),
style: recipientHeaderTextStyle(context).copyWith(
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
fontStyle: topic.displayName == null ? FontStyle.italic : null,
))),
const SizedBox(width: 4),
// TODO(design) copies the recipient header in web; is there a better color?
Icon(size: 14, color: designVariables.colorMessageHeaderIconInteractive,
Expand Down
20 changes: 20 additions & 0 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,26 @@ void main() {
check(findInMessageList('topic name')).length.equals(1);
});

final messageEmptyTopic = eg.streamMessage(stream: stream, topic: '');

testWidgets('show general chat for empty topics with channel name', (tester) async {
await setupMessageListPage(tester,
narrow: const CombinedFeedNarrow(),
messages: [messageEmptyTopic], subscriptions: [eg.subscription(stream)]);
await tester.pump();
check(findInMessageList('stream name')).single;
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
}, skip: true); // null topic names soon to be enabled

testWidgets('show general chat for empty topics without channel name', (tester) async {
await setupMessageListPage(tester,
narrow: TopicNarrow.ofMessage(messageEmptyTopic),
messages: [messageEmptyTopic]);
await tester.pump();
check(findInMessageList('stream name')).isEmpty();
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
}, skip: true); // null topic names soon to be enabled

testWidgets('show topic visibility icon when followed', (tester) async {
await setupMessageListPage(tester,
narrow: const CombinedFeedNarrow(),
Expand Down

0 comments on commit f3f9712

Please sign in to comment.