Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude deactivated users from @-mention autocomplete popup #580

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/model/autocomplete.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ class MentionAutocompleteQuery {
// TODO(#236) test email too, not just name
// TODO(#237) test with diacritics stripped, where appropriate

if (!user.isActive) return false;

final List<String> nameWords = cache.nameWordsForUser(user);

int nameWordsIndex = 0;
Expand Down
3 changes: 2 additions & 1 deletion test/example_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ User user({
String? email,
String? fullName,
String? avatarUrl,
bool? isActive,
Map<int, ProfileFieldUserData>? profileData,
}) {
return User(
Expand All @@ -68,7 +69,7 @@ User user({
email: email ?? '[email protected]', // TODO generate example emails
fullName: fullName ?? 'A user', // TODO generate example names
dateJoined: '2023-04-28',
isActive: true,
isActive: isActive ?? true,
isOwner: false,
isAdmin: false,
isGuest: false,
Expand Down
7 changes: 7 additions & 0 deletions test/model/autocomplete_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,12 @@ void main() {
doCheck('Name Four Full Words', eg.user(fullName: 'Full Name Four Words'), false);
doCheck('F Full', eg.user(fullName: 'Full Name Four Words'), false);
doCheck('Four F', eg.user(fullName: 'Full Name Four Words'), false);

// User should always be excluded in case of inactive users
doCheck('Full Name', eg.user(fullName: 'Full Name', isActive: false), false);
doCheck('Full', eg.user(fullName: 'Full Name', isActive: false), false);
// User that are already excluded will still be excluded in case of inactive users
doCheck('Fully Named', eg.user(fullName: 'Full Name', isActive: false), false);

});
}
9 changes: 8 additions & 1 deletion test/model/compose_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ world
test('whitespace around info string', () {
checkFenceWrap('''
````
``` javascript
``` javascript
// hello world
```
````
Expand Down Expand Up @@ -315,6 +315,13 @@ hello
store.addUsers([user, eg.user(userId: 5), eg.user(userId: 234, fullName: user.fullName)]);
check(mention(user, silent: true, users: store.users)).equals('@_**Full Name|123**');
});

test('`users` passed; has two users with same fullName but one of them is not active', () {
final store = eg.store();
store.addUsers([user, eg.user(userId: 5), eg.user(userId: 234, fullName: user.fullName, isActive: false)]);
check(mention(user, silent: true, users: store.users)).equals('@_**Full Name|123**');
});

test('`users` passed; user has unique fullName', () {
final store = eg.store();
store.addUsers([user, eg.user(userId: 234, fullName: 'Another Name')]);
Expand Down
Loading