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());