Skip to content

Commit 94c2949

Browse files
committed
msglist [nfc]: Display realmEmptyTopicDisplayName where empty topic appears
While this appears to be a user facing change, it's not visible yet, not until TopicName.displayName becomes nullable. This is a part of a series of changes to handle empty topics. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 6fd99ad commit 94c2949

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

lib/widgets/message_list.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,11 @@ class MessageListAppBarTitle extends StatelessWidget {
339339
return Row(
340340
mainAxisSize: MainAxisSize.min,
341341
children: [
342-
Flexible(child: Text(topic.displayName, style: const TextStyle(
342+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
343+
Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle(
343344
fontSize: 13,
345+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
346+
fontStyle: topic.displayName == null ? FontStyle.italic : null,
344347
).merge(weightVariableTextStyle(context)))),
345348
if (icon != null)
346349
Padding(
@@ -1092,11 +1095,15 @@ class StreamMessageRecipientHeader extends StatelessWidget {
10921095
child: Row(
10931096
children: [
10941097
Flexible(
1095-
child: Text(topic.displayName,
1098+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
1099+
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
10961100
// TODO: Give a way to see the whole topic (maybe a
10971101
// long-press interaction?)
10981102
overflow: TextOverflow.ellipsis,
1099-
style: recipientHeaderTextStyle(context))),
1103+
style: recipientHeaderTextStyle(context,
1104+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
1105+
fontStyle: topic.displayName == null ? FontStyle.italic : null,
1106+
))),
11001107
const SizedBox(width: 4),
11011108
Icon(size: 14, color: designVariables.title.withFadedAlpha(0.5),
11021109
// A null [Icon.icon] makes a blank space.
@@ -1191,12 +1198,13 @@ class DmRecipientHeader extends StatelessWidget {
11911198
}
11921199
}
11931200

1194-
TextStyle recipientHeaderTextStyle(BuildContext context) {
1201+
TextStyle recipientHeaderTextStyle(BuildContext context, {FontStyle? fontStyle}) {
11951202
return TextStyle(
11961203
color: DesignVariables.of(context).title,
11971204
fontSize: 16,
11981205
letterSpacing: proportionalLetterSpacing(context, 0.02, baseFontSize: 16),
11991206
height: (18 / 16),
1207+
fontStyle: fontStyle,
12001208
).merge(weightVariableTextStyle(context, wght: 600));
12011209
}
12021210

test/widgets/message_list_test.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,16 @@ void main() {
194194
group('app bar', () {
195195
// Tests for the topic action sheet are in test/widgets/action_sheet_test.dart.
196196

197+
testWidgets('handle empty topics', (tester) async {
198+
final channel = eg.stream();
199+
await setupMessageListPage(tester,
200+
narrow: eg.topicNarrow(channel.streamId, ''),
201+
streams: [channel],
202+
messageCount: 1);
203+
checkAppBarChannelTopic(
204+
channel.name, eg.defaultRealmEmptyTopicDisplayName);
205+
}, skip: true); // null topic names soon to be enabled
206+
197207
testWidgets('has channel-feed action for topic narrows', (tester) async {
198208
final pushedRoutes = <Route<void>>[];
199209
final navObserver = TestNavigatorObserver()
@@ -934,6 +944,26 @@ void main() {
934944
check(findInMessageList('topic name')).length.equals(1);
935945
});
936946

947+
final messageEmptyTopic = eg.streamMessage(stream: stream, topic: '');
948+
949+
testWidgets('show general chat for empty topics with channel name', (tester) async {
950+
await setupMessageListPage(tester,
951+
narrow: const CombinedFeedNarrow(),
952+
messages: [messageEmptyTopic], subscriptions: [eg.subscription(stream)]);
953+
await tester.pump();
954+
check(findInMessageList('stream name')).single;
955+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
956+
}, skip: true); // null topic names soon to be enabled
957+
958+
testWidgets('show general chat for empty topics without channel name', (tester) async {
959+
await setupMessageListPage(tester,
960+
narrow: TopicNarrow.ofMessage(messageEmptyTopic),
961+
messages: [messageEmptyTopic]);
962+
await tester.pump();
963+
check(findInMessageList('stream name')).isEmpty();
964+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
965+
}, skip: true); // null topic names soon to be enabled
966+
937967
testWidgets('show topic visibility icon when followed', (tester) async {
938968
await setupMessageListPage(tester,
939969
narrow: const CombinedFeedNarrow(),

0 commit comments

Comments
 (0)