Skip to content

Commit ff335a6

Browse files
gnpricechrisbobbe
authored andcommitted
new-dm: Exclude deactivated users
Fixes #1743.
1 parent d13e3d9 commit ff335a6

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

lib/widgets/new_dm_sheet.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:collection/collection.dart';
21
import 'package:flutter/material.dart';
32
import '../api/model/model.dart';
43
import '../generated/l10n/zulip_localizations.dart';
@@ -69,9 +68,9 @@ class _NewDmPickerState extends State<NewDmPicker> with PerAccountStoreAwareStat
6968
}
7069

7170
void _initSortedUsers(PerAccountStore store) {
72-
final sansMuted = store.allUsers
73-
.whereNot((user) => store.isUserMuted(user.userId));
74-
sortedUsers = List<User>.from(sansMuted)
71+
final users = store.allUsers
72+
.where((user) => user.isActive && !store.isUserMuted(user.userId));
73+
sortedUsers = List<User>.from(users)
7574
..sort((a, b) => MentionAutocompleteView.compareByDms(a, b, store: store));
7675
_updateFilteredUsers(store);
7776
}

test/widgets/new_dm_sheet_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ void main() {
140140
check(findText(includePlaceholders: false, 'Bob Brown')).findsNothing();
141141
});
142142

143+
testWidgets('deactivated users excluded', (tester) async {
144+
// Omit a deactivated user both before there's a query…
145+
final deactivatedUser = eg.user(fullName: 'Impostor Charlie', isActive: false);
146+
await setupSheet(tester, users: [...testUsers, deactivatedUser]);
147+
check(findText(includePlaceholders: false, 'Impostor Charlie')).findsNothing();
148+
check(findText(includePlaceholders: false, 'Charlie Carter')).findsOne();
149+
check(find.byIcon(ZulipIcons.check_circle_unchecked)).findsExactly(3);
150+
151+
// … and after a query that would match their name.
152+
await tester.enterText(find.byType(TextField), 'Charlie');
153+
await tester.pump();
154+
check(findText(includePlaceholders: false, 'Impostor Charlie')).findsNothing();
155+
check(findText(includePlaceholders: false, 'Charlie Carter')).findsOne();
156+
check(find.byIcon(ZulipIcons.check_circle_unchecked)).findsExactly(1);
157+
});
158+
143159
testWidgets('muted users excluded', (tester) async {
144160
// Omit muted users both before there's a query…
145161
final mutedUser = eg.user(fullName: 'Someone Muted');

0 commit comments

Comments
 (0)