From 953466029da9c6a895eca8e974039f4ab042da0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Tue, 15 Feb 2022 11:01:26 +0100 Subject: [PATCH] app: Show spinner by default instead of greeter --- data/resources/ui/session.ui | 30 +----------------------------- data/resources/ui/window.ui | 30 +++++++++++++++++++++++++++++- src/session/mod.rs | 10 +++++++++- src/window.rs | 22 ++++++++++++++++------ 4 files changed, 55 insertions(+), 37 deletions(-) diff --git a/data/resources/ui/session.ui b/data/resources/ui/session.ui index ca7d10a5..f7969d3e 100644 --- a/data/resources/ui/session.ui +++ b/data/resources/ui/session.ui @@ -4,36 +4,8 @@ true - loading + content crossfade - - - - - vertical - - - True - - - - - - True - center - center - True - - - - - - - minimum diff --git a/data/resources/ui/window.ui b/data/resources/ui/window.ui index c0cab8f4..372ffccd 100644 --- a/data/resources/ui/window.ui +++ b/data/resources/ui/window.ui @@ -16,8 +16,36 @@ - greeter + loading crossfade + + + + + vertical + + + True + + + + + + True + center + center + True + + + + + + + diff --git a/src/session/mod.rs b/src/session/mod.rs index 915b64c8..e9b1505c 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -492,6 +492,9 @@ impl Session { let widget = SessionVerification::new(self); stack.add_named(&widget, Some("session-verification")); stack.set_visible_child(&widget); + if let Some(window) = self.parent_window() { + window.switch_to_sessions_page(); + } } fn mark_ready(&self) { @@ -529,6 +532,9 @@ impl Session { let handle = spawn_tokio!(async move { client.bootstrap_cross_signing(None).await }); if handle.await.is_ok() { priv_.stack.set_visible_child(&*priv_.content); + if let Some(window) = obj.parent_window() { + window.switch_to_sessions_page(); + } return; } } @@ -737,10 +743,12 @@ impl Session { /// Show the content of the session pub fn show_content(&self) { let priv_ = self.imp(); - // FIXME: we should actually check if we have now the keys priv_.stack.set_visible_child(&*priv_.content); priv_.logout_on_dispose.set(false); + if let Some(window) = self.parent_window() { + window.switch_to_sessions_page(); + } if let Some(session_verificiation) = priv_.stack.child_by_name("session-verification") { priv_.stack.remove(&session_verificiation); diff --git a/src/window.rs b/src/window.rs index b74ac6f0..fcdddfa1 100644 --- a/src/window.rs +++ b/src/window.rs @@ -22,6 +22,8 @@ mod imp { #[template_child] pub main_stack: TemplateChild, #[template_child] + pub loading: TemplateChild, + #[template_child] pub greeter: TemplateChild, #[template_child] pub login: TemplateChild, @@ -88,7 +90,7 @@ mod imp { self.login .connect_new_session(clone!(@weak obj => move |_login, session| { obj.add_session(&session); - obj.switch_to_sessions_page(); + obj.switch_to_loading_page(); })); self.main_stack.connect_visible_child_notify( @@ -171,11 +173,14 @@ impl Window { fn restore_sessions(&self) { match secret::restore_sessions() { Ok(sessions) => { - for stored_session in sessions { - let session = Session::new(); - session.login_with_previous_session(stored_session); - self.add_session(&session); - self.switch_to_sessions_page(); + if sessions.is_empty() { + self.switch_to_greeter_page(false); + } else { + for stored_session in sessions { + let session = Session::new(); + session.login_with_previous_session(stored_session); + self.add_session(&session); + } } } Err(error) => { @@ -234,6 +239,11 @@ impl Window { } } + pub fn switch_to_loading_page(&self) { + let priv_ = self.imp(); + priv_.main_stack.set_visible_child(&*priv_.loading); + } + pub fn switch_to_sessions_page(&self) { let priv_ = self.imp(); priv_.main_stack.set_visible_child(&priv_.sessions.get());