Skip to content

Commit 50e8ca5

Browse files
committed
autocomplete: Remove the refreshStaleUserResults method
This method was used to search for the new user results in autocomplete when the users in store were modified during an in-progress computation. Along with this, `_startSearch` would do the same thing by retrying, resulting in duplicate actions. By removing this, the unnecessary search for user results is prevented. Besides, this commit also removes some live-updating behavior of user-mention autocomplete results in order to provide a better UX. To read more about this decision, see: #693 (review)
1 parent 177b719 commit 50e8ca5

File tree

3 files changed

+2
-22
lines changed

3 files changed

+2
-22
lines changed

lib/model/autocomplete.dart

-21
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,11 @@ class AutocompleteViewManager {
125125
assert(removed);
126126
}
127127

128-
void handleRealmUserAddEvent(RealmUserAddEvent event) {
129-
for (final view in _mentionAutocompleteViews) {
130-
view.refreshStaleUserResults();
131-
}
132-
}
133-
134128
void handleRealmUserRemoveEvent(RealmUserRemoveEvent event) {
135-
for (final view in _mentionAutocompleteViews) {
136-
view.refreshStaleUserResults();
137-
}
138129
autocompleteDataCache.invalidateUser(event.userId);
139130
}
140131

141132
void handleRealmUserUpdateEvent(RealmUserUpdateEvent event) {
142-
for (final view in _mentionAutocompleteViews) {
143-
view.refreshStaleUserResults();
144-
}
145133
autocompleteDataCache.invalidateUser(event.userId);
146134
}
147135

@@ -208,15 +196,6 @@ class MentionAutocompleteView extends ChangeNotifier {
208196
}
209197
}
210198

211-
/// Recompute user results for the current query, if any.
212-
///
213-
/// Called in particular when we get a [RealmUserEvent].
214-
void refreshStaleUserResults() {
215-
if (_query != null) {
216-
_startSearch(_query!);
217-
}
218-
}
219-
220199
/// Called when the app is reassembled during debugging, e.g. for hot reload.
221200
///
222201
/// This will redo the search from scratch for the current query, if any.

lib/model/store.dart

-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ class PerAccountStore extends ChangeNotifier with StreamStore, MessageStore {
418418
} else if (event is RealmUserAddEvent) {
419419
assert(debugLog("server event: realm_user/add"));
420420
users[event.person.userId] = event.person;
421-
autocompleteViewManager.handleRealmUserAddEvent(event);
422421
notifyListeners();
423422
} else if (event is RealmUserRemoveEvent) {
424423
assert(debugLog("server event: realm_user/remove"));

test/model/autocomplete_test.dart

+2
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ void main() {
289289
await Future(() {});
290290
check(done).isFalse();
291291
await store.addUser(eg.user(userId: 10000, email: '[email protected]', fullName: 'User 10000'));
292+
check(done).isFalse();
293+
await Future(() {});
292294
await Future(() {});
293295
check(done).isFalse();
294296
await Future(() {});

0 commit comments

Comments
 (0)