Skip to content

Commit 81feda5

Browse files
Khader-1gnprice
authored andcommitted
autocomplete: Exclude user from autocomplete popup if deactivated
Deactivated users can not be mentioned, so this commit ensures that deactivated users are excluded from the list that gets rendered in autocomplete popup. Fixes: #451
1 parent 1261b5a commit 81feda5

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/model/autocomplete.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ class MentionAutocompleteQuery {
288288
bool testUser(User user, AutocompleteDataCache cache) {
289289
// TODO(#236) test email too, not just name
290290

291+
if (!user.isActive) return false;
292+
291293
return _testName(user, cache);
292294
}
293295

test/model/autocomplete_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ void main() {
312312
expected ? check(result).isTrue() : check(result).isFalse();
313313
}
314314

315+
test('user is always excluded when not active regardless of other criteria', () {
316+
doCheck('Full Name', eg.user(fullName: 'Full Name', isActive: false), false);
317+
// When active then other criteria will be checked
318+
doCheck('Full Name', eg.user(fullName: 'Full Name', isActive: true), true);
319+
});
320+
315321
test('user is included if fullname words match the query', () {
316322
doCheck('', eg.user(fullName: 'Full Name'), true);
317323
doCheck('', eg.user(fullName: ''), true); // Unlikely case, but should not crash

0 commit comments

Comments
 (0)