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;
}
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
@ -986,10 +986,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
@ -2219,7 +2218,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);
}
}

View file

@ -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
);
}
}

View file

@ -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;
/**

View file

@ -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);
}

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,
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>?