[gnome-contacts] SearchProvider: add timeout for checking results
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] SearchProvider: add timeout for checking results
- Date: Mon, 19 Aug 2019 23:20:04 +0000 (UTC)
commit 3a7b7c301156f9e646703a90b72eecfba76f0dba
Author: Julian Sparber <julian sparber net>
Date: Tue Jul 30 11:48:08 2019 +0200
SearchProvider: add timeout for checking results
src/contacts-shell-search-provider.vala | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/contacts-shell-search-provider.vala b/src/contacts-shell-search-provider.vala
index f85289e..7465d56 100644
--- a/src/contacts-shell-search-provider.vala
+++ b/src/contacts-shell-search-provider.vala
@@ -43,14 +43,31 @@ public class Contacts.SearchProvider : Object {
}
public async string[] GetInitialResultSet (string[] terms) throws Error {
- /* Wait that the aggregator has prepared all data or the search will be empty */
+ /* Wait that the aggregator has prepared some data or the search will be empty */
if (!this.aggregator.is_quiescent) {
- this.aggregator.notify["is-quiescent"].connect(() => {
+ var id = this.aggregator.notify["is-quiescent"].connect(() => {
GetInitialResultSet.callback ();
});
+
+ // Add timeout for 1.5s so we can check if we already have some results
+ var timeout = Timeout.add (1500, () => {
+ GetInitialResultSet.callback ();
+ return false;
+ });
yield;
+ Source.remove (timeout);
+ this.aggregator.disconnect (id);
+
+ var results = yield do_search (terms);
+ if (results.length == 0) {
+ // We still don't have any results wait some more
+ return yield GetInitialResultSet (terms);
+ } else {
+ return results;
+ }
+ } else {
+ return yield do_search (terms);
}
- return yield do_search (terms);
}
public async string[] GetSubsearchResultSet (string[] previous_results, string[] new_terms)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]