Skip to content

Commit e78fb98

Browse files
committed
poll: Distinguish muted users in polls
1 parent 50fb66d commit e78fb98

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/widgets/poll.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ class _PollWidgetState extends State<PollWidget> {
8080
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya', 'Zixuan'])
8181
// // 'Chris、Greg、Alya、Zixuan'
8282
final voterNames = option.voters
83-
.map(store.userDisplayName)
83+
.map((userId) =>
84+
store.isUserMuted(userId)
85+
? zulipLocalizations.mutedUser
86+
: store.userDisplayName(userId))
8487
.join(', ');
8588

8689
return Row(

test/widgets/poll_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:flutter_checks/flutter_checks.dart';
77
import 'package:flutter_test/flutter_test.dart';
88
import 'package:zulip/api/model/model.dart';
99
import 'package:zulip/api/model/submessage.dart';
10+
import 'package:zulip/model/localizations.dart';
1011
import 'package:zulip/model/store.dart';
1112
import 'package:zulip/widgets/poll.dart';
1213

@@ -28,12 +29,14 @@ void main() {
2829
WidgetTester tester,
2930
SubmessageData? submessageContent, {
3031
Iterable<User>? users,
32+
List<int>? mutedUserIds,
3133
Iterable<(User, int)> voterIdxPairs = const [],
3234
}) async {
3335
addTearDown(testBinding.reset);
3436
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
3537
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
3638
await store.addUsers(users ?? [eg.selfUser, eg.otherUser]);
39+
await store.muteUsers(mutedUserIds ?? []);
3740
connection = store.connection as FakeApiConnection;
3841

3942
message = eg.streamMessage(
@@ -96,6 +99,21 @@ void main() {
9699
check(findTextAtRow('100', index: 0)).findsOne();
97100
});
98101

102+
testWidgets('muted voters', (tester) async {
103+
final user1 = eg.user(userId: 1, fullName: 'User 1');
104+
final user2 = eg.user(userId: 2, fullName: 'User 2');
105+
await preparePollWidget(tester, pollWidgetData,
106+
users: [user1, user2],
107+
mutedUserIds: [user2.userId],
108+
voterIdxPairs: [(user1, 0), (user2, 0), (user2, 1)]);
109+
110+
final localizations = GlobalLocalizations.zulipLocalizations;
111+
check(findTextAtRow(
112+
'(${store.userDisplayName(user1.userId)}, ${localizations.mutedUser})',
113+
index: 0)).findsOne();
114+
check(findTextAtRow('(${localizations.mutedUser})', index: 1)).findsOne();
115+
});
116+
99117
testWidgets('show unknown voter', (tester) async {
100118
await preparePollWidget(tester, pollWidgetData,
101119
users: [eg.selfUser], voterIdxPairs: [(eg.thirdUser, 1)]);

0 commit comments

Comments
 (0)