Skip to content

Commit 982aefd

Browse files
committed
inbox: Add label for archived channels in headers
Design inspired by the web version. Fixes #800
1 parent b29c004 commit 982aefd

16 files changed

+248
-35
lines changed

assets/l10n/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@
375375
"@unknownChannelName": {
376376
"description": "Replacement name for channel when it cannot be found in the store."
377377
},
378+
"channelArchivedLabel": "(archived)",
379+
"@channelArchivedLabel": {
380+
"description": "Label shown next to an archived channel's name in headers."
381+
},
378382
"composeBoxTopicHintText": "Topic",
379383
"@composeBoxTopicHintText": {
380384
"description": "Hint text for topic input widget in compose box."

lib/generated/l10n/zulip_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,12 @@ abstract class ZulipLocalizations {
603603
/// **'(unknown channel)'**
604604
String get unknownChannelName;
605605

606+
/// Label shown next to an archived channel's name in headers.
607+
///
608+
/// In en, this message translates to:
609+
/// **'(archived)'**
610+
String get channelArchivedLabel;
611+
606612
/// Hint text for topic input widget in compose box.
607613
///
608614
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
295295
@override
296296
String get unknownChannelName => '(unknown channel)';
297297

298+
@override
299+
String get channelArchivedLabel => '(archived)';
300+
298301
@override
299302
String get composeBoxTopicHintText => 'Topic';
300303

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
295295
@override
296296
String get unknownChannelName => '(unknown channel)';
297297

298+
@override
299+
String get channelArchivedLabel => '(archived)';
300+
298301
@override
299302
String get composeBoxTopicHintText => 'Topic';
300303

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
295295
@override
296296
String get unknownChannelName => '(unknown channel)';
297297

298+
@override
299+
String get channelArchivedLabel => '(archived)';
300+
298301
@override
299302
String get composeBoxTopicHintText => 'Topic';
300303

lib/generated/l10n/zulip_localizations_nb.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
295295
@override
296296
String get unknownChannelName => '(unknown channel)';
297297

298+
@override
299+
String get channelArchivedLabel => '(archived)';
300+
298301
@override
299302
String get composeBoxTopicHintText => 'Topic';
300303

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
295295
@override
296296
String get unknownChannelName => '(nieznany kanał)';
297297

298+
@override
299+
String get channelArchivedLabel => '(archived)';
300+
298301
@override
299302
String get composeBoxTopicHintText => 'Wątek';
300303

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
295295
@override
296296
String get unknownChannelName => '(unknown channel)';
297297

298+
@override
299+
String get channelArchivedLabel => '(archived)';
300+
298301
@override
299302
String get composeBoxTopicHintText => 'Тема';
300303

lib/generated/l10n/zulip_localizations_sk.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
295295
@override
296296
String get unknownChannelName => '(unknown channel)';
297297

298+
@override
299+
String get channelArchivedLabel => '(archived)';
300+
298301
@override
299302
String get composeBoxTopicHintText => 'Topic';
300303

lib/widgets/action_sheet.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,22 @@ void showTopicActionSheet(BuildContext context, {
230230
final pageContext = PageRoot.contextOf(context);
231231

232232
final store = PerAccountStoreWidget.of(pageContext);
233+
final channel = store.streams[channelId];
233234
final subscription = store.subscriptions[channelId];
234235

235236
final optionButtons = <ActionSheetMenuItemButton>[];
236237

238+
final isChannelArchived = channel?.isArchived == true;
237239
// TODO(server-7): simplify this condition away
238240
final supportsUnmutingTopics = store.zulipFeatureLevel >= 170;
239241
// TODO(server-8): simplify this condition away
240242
final supportsFollowingTopics = store.zulipFeatureLevel >= 219;
241243

242244
final visibilityOptions = <UserTopicVisibilityPolicy>[];
243245
final visibilityPolicy = store.topicVisibilityPolicy(channelId, topic);
244-
if (subscription == null) {
245-
// Not subscribed to the channel; there is no user topic change to be made.
246+
if (subscription == null || isChannelArchived) {
247+
// Not subscribed to the channel or the channel is archived;
248+
// there is no user topic change to be made.
246249
} else if (!subscription.isMuted) {
247250
// Channel is subscribed and not muted.
248251
switch (visibilityPolicy) {
@@ -306,7 +309,8 @@ void showTopicActionSheet(BuildContext context, {
306309
// limit for editing topics).
307310
if (someMessageIdInTopic != null
308311
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
309-
&& topic.displayName != null) {
312+
&& topic.displayName != null
313+
&& !isChannelArchived) {
310314
optionButtons.add(ResolveUnresolveButton(pageContext: pageContext,
311315
topic: topic,
312316
someMessageIdInTopic: someMessageIdInTopic));
@@ -564,14 +568,19 @@ void showMessageActionSheet({required BuildContext context, required Message mes
564568
final messageListPage = MessageListPage.ancestorOf(pageContext);
565569
final isComposeBoxOffered = messageListPage.composeBoxController != null;
566570

571+
bool isInArchivedChannel = false;
572+
if (message is StreamMessage) {
573+
final channel = store.streams[message.streamId];
574+
isInArchivedChannel = channel?.isArchived == true;
575+
}
567576
final isMessageRead = message.flags.contains(MessageFlag.read);
568577
final markAsUnreadSupported = store.zulipFeatureLevel >= 155; // TODO(server-6)
569578
final showMarkAsUnreadButton = markAsUnreadSupported && isMessageRead;
570579

571580
final optionButtons = [
572581
ReactionButtons(message: message, pageContext: pageContext),
573582
StarButton(message: message, pageContext: pageContext),
574-
if (isComposeBoxOffered)
583+
if (isComposeBoxOffered && !isInArchivedChannel)
575584
QuoteAndReplyButton(message: message, pageContext: pageContext),
576585
if (showMarkAsUnreadButton)
577586
MarkAsUnreadButton(message: message, pageContext: pageContext),

0 commit comments

Comments
 (0)