Skip to content

Commit 23c3025

Browse files
committed
recent-dms: Distinguish muted users in recent DMs page
1 parent 2a0dfd6 commit 23c3025

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

lib/widgets/recent_dm_conversations.dart

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22

3+
import '../generated/l10n/zulip_localizations.dart';
34
import '../model/narrow.dart';
45
import '../model/recent_dm_conversations.dart';
56
import '../model/unreads.dart';
@@ -79,6 +80,7 @@ class RecentDmConversationsItem extends StatelessWidget {
7980
@override
8081
Widget build(BuildContext context) {
8182
final store = PerAccountStoreWidget.of(context);
83+
final localizations = ZulipLocalizations.of(context);
8284
final designVariables = DesignVariables.of(context);
8385

8486
final String title;
@@ -88,16 +90,26 @@ class RecentDmConversationsItem extends StatelessWidget {
8890
title = store.selfUser.fullName;
8991
avatar = AvatarImage(userId: store.selfUserId, size: _avatarSize);
9092
case [var otherUserId]:
91-
// TODO(#296) actually don't show this row if the user is muted?
92-
// (should we offer a "spam folder" style summary screen of recent
93-
// 1:1 DM conversations from muted users?)
94-
title = store.userDisplayName(otherUserId);
95-
avatar = AvatarImage(userId: otherUserId, size: _avatarSize);
93+
// Although we currently don't display a DM conversation with a muted
94+
// user, maybe in the future we will have the "Search by location"
95+
// feature similar to Web where a DM conversation with a muted user is
96+
// displayed if searched for explicitly; for example using: "dm:Bo Lin".
97+
// https://zulip.com/help/search-for-messages#search-by-location
98+
final isUserMuted = store.isUserMuted(otherUserId);
99+
title = isUserMuted
100+
? localizations.mutedUser
101+
: store.userDisplayName(otherUserId);
102+
avatar = isUserMuted
103+
? AvatarPlaceholder(size: _avatarSize)
104+
: AvatarImage(userId: otherUserId, size: _avatarSize);
96105
default:
97106
// TODO(i18n): List formatting, like you can do in JavaScript:
98107
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya'])
99108
// // 'Chris、Greg、Alya'
100-
title = narrow.otherRecipientIds.map(store.userDisplayName)
109+
title = narrow.otherRecipientIds.map((id) =>
110+
store.isUserMuted(id)
111+
? localizations.mutedUser
112+
: store.userDisplayName(id))
101113
.join(', ');
102114
avatar = ColoredBox(color: designVariables.groupDmConversationIconBg,
103115
child: Center(

0 commit comments

Comments
 (0)