Skip to content

Commit 8b4f059

Browse files
committed
action_sheet [nfc]: Hide resolve/unresolve button for empty topic
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 580474b commit 8b4f059

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

lib/widgets/action_sheet.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ void showTopicActionSheet(BuildContext context, {
300300
pageContext: pageContext);
301301
}));
302302

303-
if (someMessageIdInTopic != null) {
303+
// TODO: check for other cases that may disallow this action (e.g.: time
304+
// limit for editing topics).
305+
if (someMessageIdInTopic != null
306+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
307+
&& topic.displayName != null) {
304308
optionButtons.add(ResolveUnresolveButton(pageContext: pageContext,
305309
topic: topic,
306310
someMessageIdInTopic: someMessageIdInTopic));

test/widgets/action_sheet_test.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,19 +358,21 @@ void main() {
358358
}) async {
359359
final effectiveChannel = channel ?? someChannel;
360360
final effectiveMessages = messages ?? [someMessage];
361-
assert(effectiveMessages.every((m) => m.topic.apiName == topic));
361+
final topicName = TopicName(topic);
362+
assert(effectiveMessages.every((m) => m.topic.apiName == topicName.apiName));
362363

363364
connection.prepare(json: eg.newestGetMessagesResult(
364365
foundOldest: true, messages: effectiveMessages).toJson());
365366
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
366367
child: MessageListPage(
367-
initNarrow: eg.topicNarrow(effectiveChannel.streamId, topic))));
368+
initNarrow: eg.topicNarrow(effectiveChannel.streamId, topicName.apiName))));
368369
// global store, per-account store, and message list get loaded
369370
await tester.pumpAndSettle();
370371

371372
final topicRow = find.descendant(
372373
of: find.byType(ZulipAppBar),
373-
matching: find.text(topic));
374+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
375+
matching: find.text(topicName.displayName ?? eg.defaultRealmEmptyTopicDisplayName));
374376
await tester.longPress(topicRow);
375377
// sheet appears onscreen; default duration of bottom-sheet enter animation
376378
await tester.pump(const Duration(milliseconds: 250));
@@ -446,6 +448,16 @@ void main() {
446448
check(findButtonForLabel('Mark as unresolved')).findsNothing();
447449
});
448450

451+
testWidgets('show from app bar: resolve/unresolve not offered when topic is empty', (tester) async {
452+
await prepare();
453+
final message = eg.streamMessage(stream: someChannel, topic: '');
454+
await showFromAppBar(tester,
455+
topic: '',
456+
messages: [message]);
457+
check(findButtonForLabel('Mark as resolved')).findsNothing();
458+
check(findButtonForLabel('Mark as unresolved')).findsNothing();
459+
}, skip: true); // null topic names soon to be enabled
460+
449461
testWidgets('show from recipient header', (tester) async {
450462
await prepare();
451463
await showFromRecipientHeader(tester);

0 commit comments

Comments
 (0)