Skip to content

Commit d0c9e52

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, check out zulip#693 (review))
1 parent 75004d7 commit d0c9e52

File tree

2 files changed

+0
-22
lines changed

2 files changed

+0
-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
@@ -413,7 +413,6 @@ class PerAccountStore extends ChangeNotifier with StreamStore {
413413
} else if (event is RealmUserAddEvent) {
414414
assert(debugLog("server event: realm_user/add"));
415415
users[event.person.userId] = event.person;
416-
autocompleteViewManager.handleRealmUserAddEvent(event);
417416
notifyListeners();
418417
} else if (event is RealmUserRemoveEvent) {
419418
assert(debugLog("server event: realm_user/remove"));

0 commit comments

Comments
 (0)