[geary/mjog/search-update: 11/17] Geary.Account: Make new_search_query synchronous
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/search-update: 11/17] Geary.Account: Make new_search_query synchronous
- Date: Mon, 28 Dec 2020 09:33:40 +0000 (UTC)
commit 379ecc60d661b3401fc0d82ff5ed9c1faf50f01e
Author: Michael Gratton <mike vee net>
Date: Thu Nov 5 18:56:11 2020 +1100
Geary.Account: Make new_search_query synchronous
Constructing a new query should be fast, and it no longer needs to be
done async, so remove async from the method and simplify callers.
src/client/application/application-main-window.vala | 9 ++++-----
src/client/conversation-viewer/conversation-viewer.vala | 17 ++++++-----------
src/engine/api/geary-account.vala | 5 ++---
src/engine/imap-engine/imap-engine-generic-account.vala | 5 ++---
test/mock/mock-account.vala | 7 +++----
5 files changed, 17 insertions(+), 26 deletions(-)
---
diff --git a/src/client/application/application-main-window.vala
b/src/client/application/application-main-window.vala
index b5e7be785..394111026 100644
--- a/src/client/application/application-main-window.vala
+++ b/src/client/application/application-main-window.vala
@@ -943,7 +943,7 @@ public class Application.MainWindow :
return closed;
}
- internal async void start_search(string query_text, bool is_interactive) {
+ internal void start_search(string query_text, bool is_interactive) {
var context = get_selected_account_context();
if (context != null) {
// Stop any search in progress
@@ -961,10 +961,9 @@ public class Application.MainWindow :
this.application.config.get_search_strategy(),
context.account.information
);
- var query = yield context.account.new_search_query(
+ var query = context.account.new_search_query(
expr_factory.parse_query(query_text),
- query_text,
- cancellable
+ query_text
);
this.folder_list.set_search(
this.application.engine, context.search
@@ -2177,7 +2176,7 @@ public class Application.MainWindow :
if (Geary.String.is_empty_or_whitespace(text)) {
stop_search(true);
} else {
- this.start_search.begin(text, true);
+ this.start_search(text, true);
}
}
diff --git a/src/client/conversation-viewer/conversation-viewer.vala
b/src/client/conversation-viewer/conversation-viewer.vala
index cc115e6d1..b28dc8d7a 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -297,9 +297,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
// Highlight matching terms from find if active, otherwise
// from the search folder if that's where we are at
- Geary.SearchQuery? query = yield get_find_search_query(
- conversation.base_folder.account, null
- );
+ var query = get_find_search_query(conversation.base_folder.account);
if (query == null) {
var search_folder = conversation.base_folder as Geary.App.SearchFolder;
if (search_folder != null) {
@@ -406,9 +404,8 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
});
this.find_cancellable = cancellable;
try {
- Geary.SearchQuery? query = yield get_find_search_query(
- list.conversation.base_folder.account,
- cancellable
+ var query = get_find_search_query(
+ list.conversation.base_folder.account
);
if (query != null) {
yield list.search.highlight_matching_email(query, true);
@@ -419,8 +416,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
}
}
- private async Geary.SearchQuery? get_find_search_query(Geary.Account account,
- GLib.Cancellable? cancellable)
+ private Geary.SearchQuery? get_find_search_query(Geary.Account account)
throws GLib.Error {
Geary.SearchQuery? query = null;
if (this.conversation_find_bar.get_search_mode()) {
@@ -433,10 +429,9 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
this.config.get_search_strategy(),
account.information
);
- query = yield account.new_search_query(
+ query = account.new_search_query(
expr_factory.parse_query(text),
- text,
- cancellable
+ text
);
}
}
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index 6bba6b90c..bc887459b 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -514,10 +514,9 @@ public abstract class Geary.Account : BaseObject, Logging.Source {
/**
* Create a new search query for this account.
*/
- public abstract async SearchQuery new_search_query(
+ public abstract SearchQuery new_search_query(
Gee.List<SearchQuery.Term> expression,
- string text,
- GLib.Cancellable? cancellable
+ string text
) throws GLib.Error;
/**
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 68ed4efcf..c3ae26038 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -575,10 +575,9 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
}
/** {@inheritDoc} */
- public override async SearchQuery new_search_query(
+ public override SearchQuery new_search_query(
Gee.List<SearchQuery.Term> expression,
- string text,
- GLib.Cancellable? cancellable
+ string text
) throws GLib.Error {
return new FtsSearchQuery(expression, text, this.stemmer);
}
diff --git a/test/mock/mock-account.vala b/test/mock/mock-account.vala
index 2d08314d0..f617f9693 100644
--- a/test/mock/mock-account.vala
+++ b/test/mock/mock-account.vala
@@ -222,12 +222,11 @@ public class Mock.Account : Geary.Account,
);
}
- public override async Geary.SearchQuery new_search_query(
+ public override Geary.SearchQuery new_search_query(
Gee.List<Geary.SearchQuery.Term> expression,
- string raw,
- GLib.Cancellable? cancellable
+ string text
) throws GLib.Error {
- return new SearchQuery(expression, raw);
+ return new SearchQuery(expression, text);
}
public override async Gee.Collection<Geary.EmailIdentifier>?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]