Add preference for restoring your most recent sign in
This commit is contained in:
@@ -186,6 +186,7 @@ impl Component for App {
|
||||
|
||||
model.register_actions();
|
||||
|
||||
if config.general.restore_most_recent_login {
|
||||
if let Some(MostRecentLogin {
|
||||
server_id,
|
||||
account_id,
|
||||
@@ -203,6 +204,7 @@ impl Component for App {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
}
|
||||
|
@@ -53,11 +53,24 @@ pub struct MostRecentLogin {
|
||||
pub account_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(default)]
|
||||
pub struct GeneralConfig {
|
||||
pub language: Option<LanguageIdentifier>,
|
||||
pub theme: Theme,
|
||||
pub most_recent_login: Option<MostRecentLogin>,
|
||||
pub restore_most_recent_login: bool,
|
||||
}
|
||||
|
||||
impl Default for GeneralConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
language: Option::default(),
|
||||
theme: Theme::default(),
|
||||
most_recent_login: Option::default(),
|
||||
restore_most_recent_login: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GeneralConfig {
|
||||
|
@@ -147,6 +147,7 @@ italic = false
|
||||
language: None,
|
||||
theme: THEME_DARK,
|
||||
most_recent_login: None,
|
||||
..Default::default()
|
||||
},
|
||||
video_player: VideoPlayerConfig {
|
||||
volume: 0.0,
|
||||
|
@@ -18,6 +18,7 @@ pub struct GeneralPreferences;
|
||||
pub enum GeneralPreferencesInput {
|
||||
Language(Option<String>),
|
||||
ThemeChanged(u32),
|
||||
RestoreMostRecentLogin(bool),
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
@@ -81,6 +82,15 @@ impl SimpleComponent for GeneralPreferences {
|
||||
sender.input(GeneralPreferencesInput::ThemeChanged(cb.selected()));
|
||||
},
|
||||
},
|
||||
|
||||
add = &adw::SwitchRow {
|
||||
set_title: tr!("prefs-general-restore-most-recent.title"),
|
||||
set_subtitle: tr!("prefs-general-restore-most-recent.subtitle"),
|
||||
set_active: general_preferences.restore_most_recent_login,
|
||||
connect_active_notify[sender] => move |switch| {
|
||||
sender.input(GeneralPreferencesInput::RestoreMostRecentLogin(switch.is_active()));
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -109,6 +119,9 @@ impl SimpleComponent for GeneralPreferences {
|
||||
GeneralPreferencesInput::ThemeChanged(theme) => {
|
||||
config.general.set_theme(Theme::from(theme));
|
||||
}
|
||||
GeneralPreferencesInput::RestoreMostRecentLogin(restore_most_recent_login) => {
|
||||
config.general.restore_most_recent_login = restore_most_recent_login;
|
||||
}
|
||||
}
|
||||
|
||||
config.save().expect("Error saving config");
|
||||
|
@@ -16,6 +16,10 @@ prefs-general-theme =
|
||||
.option-light = Light
|
||||
.option-dark = Dark
|
||||
|
||||
prefs-general-restore-most-recent =
|
||||
.title = Sign in automatically when { app-name } starts
|
||||
.subtitle = On startup, you will be signed in to your most recently used account
|
||||
|
||||
# Interface
|
||||
# =========
|
||||
|
||||
|
Reference in New Issue
Block a user