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.
This commit is contained in:
Michael Gratton 2020-11-05 18:56:11 +11:00 committed by Michael James Gratton
parent 9cb3a0d98c
commit 9bd2359464
5 changed files with 17 additions and 26 deletions

View file

@ -968,7 +968,7 @@ public class Application.MainWindow :
return closed; 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(); var context = get_selected_account_context();
if (context != null) { if (context != null) {
// Stop any search in progress // Stop any search in progress
@ -986,10 +986,9 @@ public class Application.MainWindow :
this.application.config.get_search_strategy(), this.application.config.get_search_strategy(),
context.account.information context.account.information
); );
var query = yield context.account.new_search_query( var query = context.account.new_search_query(
expr_factory.parse_query(query_text), expr_factory.parse_query(query_text),
query_text, query_text
cancellable
); );
this.folder_list.set_search( this.folder_list.set_search(
this.application.engine, context.search this.application.engine, context.search
@ -2219,7 +2218,7 @@ public class Application.MainWindow :
if (Geary.String.is_empty_or_whitespace(text)) { if (Geary.String.is_empty_or_whitespace(text)) {
stop_search(true); stop_search(true);
} else { } else {
this.start_search.begin(text, true); this.start_search(text, true);
} }
} }

View file

@ -297,9 +297,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
// Highlight matching terms from find if active, otherwise // Highlight matching terms from find if active, otherwise
// from the search folder if that's where we are at // from the search folder if that's where we are at
Geary.SearchQuery? query = yield get_find_search_query( var query = get_find_search_query(conversation.base_folder.account);
conversation.base_folder.account, null
);
if (query == null) { if (query == null) {
var search_folder = conversation.base_folder as Geary.App.SearchFolder; var search_folder = conversation.base_folder as Geary.App.SearchFolder;
if (search_folder != null) { if (search_folder != null) {
@ -406,9 +404,8 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
}); });
this.find_cancellable = cancellable; this.find_cancellable = cancellable;
try { try {
Geary.SearchQuery? query = yield get_find_search_query( var query = get_find_search_query(
list.conversation.base_folder.account, list.conversation.base_folder.account
cancellable
); );
if (query != null) { if (query != null) {
yield list.search.highlight_matching_email(query, true); 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, private Geary.SearchQuery? get_find_search_query(Geary.Account account)
GLib.Cancellable? cancellable)
throws GLib.Error { throws GLib.Error {
Geary.SearchQuery? query = null; Geary.SearchQuery? query = null;
if (this.conversation_find_bar.get_search_mode()) { if (this.conversation_find_bar.get_search_mode()) {
@ -433,10 +429,9 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
this.config.get_search_strategy(), this.config.get_search_strategy(),
account.information account.information
); );
query = yield account.new_search_query( query = account.new_search_query(
expr_factory.parse_query(text), expr_factory.parse_query(text),
text, text
cancellable
); );
} }
} }

View file

@ -514,10 +514,9 @@ public abstract class Geary.Account : BaseObject, Logging.Source {
/** /**
* Create a new search query for this account. * 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, Gee.List<SearchQuery.Term> expression,
string text, string text
GLib.Cancellable? cancellable
) throws GLib.Error; ) throws GLib.Error;
/** /**

View file

@ -575,10 +575,9 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
public override async SearchQuery new_search_query( public override SearchQuery new_search_query(
Gee.List<SearchQuery.Term> expression, Gee.List<SearchQuery.Term> expression,
string text, string text
GLib.Cancellable? cancellable
) throws GLib.Error { ) throws GLib.Error {
return new FtsSearchQuery(expression, text, this.stemmer); return new FtsSearchQuery(expression, text, this.stemmer);
} }

View file

@ -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, Gee.List<Geary.SearchQuery.Term> expression,
string raw, string text
GLib.Cancellable? cancellable
) throws GLib.Error { ) throws GLib.Error {
return new SearchQuery(expression, raw); return new SearchQuery(expression, text);
} }
public override async Gee.Collection<Geary.EmailIdentifier>? public override async Gee.Collection<Geary.EmailIdentifier>?