[geary/mjog/406-offline-infobar-delay] Application.Controller: Delay showing infobar whe going offline
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/406-offline-infobar-delay] Application.Controller: Delay showing infobar whe going offline
- Date: Wed, 18 Mar 2020 02:56:08 +0000 (UTC)
commit e109a0cf3ed80004dca6aa34390193323f6da0c9
Author: Michael Gratton <mike vee net>
Date: Wed Mar 18 13:53:26 2020 +1100
Application.Controller: Delay showing infobar whe going offline
Wait 10s before showing the offline infobar to avoid having it flash
up when network connections are temporarily lost, e.g. when resuming
from suspend.
Fixes #406
src/client/application/application-controller.vala | 31 ++++++++++++++++------
1 file changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/client/application/application-controller.vala
b/src/client/application/application-controller.vala
index dea82bb7..fc13d7d9 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -91,6 +91,9 @@ internal class Application.Controller : Geary.BaseObject {
// Requested mailto composers not yet fullfulled
private Gee.List<string?> pending_mailtos = new Gee.ArrayList<string>();
+ // Timeout controller for displaying the offline status bar
+ private Geary.TimeoutManager offline_timeout;
+
/**
* Emitted when an account is added or is enabled.
@@ -185,6 +188,10 @@ internal class Application.Controller : Geary.BaseObject {
application.engine.account_available.connect(on_account_available);
+ this.offline_timeout = new Geary.TimeoutManager.seconds(
+ 10, () => update_account_status(false)
+ );
+
this.account_manager = new Accounts.Manager(
libsecret,
this.application.get_user_config_directory(),
@@ -1005,7 +1012,7 @@ internal class Application.Controller : Geary.BaseObject {
}
}
- private void update_account_status() {
+ private void update_account_status(bool delay_offline = true) {
// Start off assuming all accounts are online and error free
// (i.e. no status issues to indicate) and proceed until
// proven incorrect.
@@ -1028,13 +1035,21 @@ internal class Application.Controller : Geary.BaseObject {
has_cert_error |= context.tls_validation_failed;
}
- foreach (MainWindow window in this.application.get_main_windows()) {
- window.update_account_status(
- effective_status,
- has_auth_error,
- has_cert_error,
- service_problem_source
- );
+ // Don't show the offline bar right away, wait a few seconds
+ // in case the host is currently resuming and the network is
+ // already coming back up
+ if (!effective_status.is_online() && delay_offline) {
+ this.offline_timeout.start();
+ } else {
+ this.offline_timeout.reset();
+ foreach (MainWindow window in this.application.get_main_windows()) {
+ window.update_account_status(
+ effective_status,
+ has_auth_error,
+ has_cert_error,
+ service_problem_source
+ );
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]