[geary/mjog/search-update: 41/53] Geary.App.SearchFolder: Only update search if query is different
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/search-update: 41/53] Geary.App.SearchFolder: Only update search if query is different
- Date: Thu, 14 Jan 2021 10:29:37 +0000 (UTC)
commit 7b86f73b475f0cf4ed5b1e76fc3aa2d515dca657
Author: Michael Gratton <mike vee net>
Date: Thu Nov 5 00:49:57 2020 +1100
Geary.App.SearchFolder: Only update search if query is different
This prevents re-running a search for e.g. whitespace-only changes.
src/engine/app/app-search-folder.vala | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
---
diff --git a/src/engine/app/app-search-folder.vala b/src/engine/app/app-search-folder.vala
index 0ad7552f2..981cb5a79 100644
--- a/src/engine/app/app-search-folder.vala
+++ b/src/engine/app/app-search-folder.vala
@@ -153,27 +153,29 @@ public class Geary.App.SearchFolder :
*/
public async void search(SearchQuery query, GLib.Cancellable? cancellable)
throws GLib.Error {
- int result_mutex_token = yield result_mutex.claim_async();
+ if (this.query == null || !this.query.equal_to(query)) {
+ int result_mutex_token = yield result_mutex.claim_async();
- clear();
+ clear();
- if (cancellable != null) {
- GLib.Cancellable @internal = this.executing;
- cancellable.cancelled.connect(() => { @internal.cancel(); });
- }
+ if (cancellable != null) {
+ GLib.Cancellable @internal = this.executing;
+ cancellable.cancelled.connect(() => { @internal.cancel(); });
+ }
- this.query = query;
- GLib.Error? error = null;
- try {
- yield do_search_async(null, null, this.executing);
- } catch(Error e) {
- error = e;
- }
+ this.query = query;
+ GLib.Error? error = null;
+ try {
+ yield do_search_async(null, null, this.executing);
+ } catch(Error e) {
+ error = e;
+ }
- result_mutex.release(ref result_mutex_token);
+ result_mutex.release(ref result_mutex_token);
- if (error != null) {
- throw error;
+ if (error != null) {
+ throw error;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]