mirror of
https://github.com/spartanz51/tutabridge.git
synced 2026-06-24 10:54:32 +02:00
GUI: fix first-run onboarding when no account exists
The dashboard only ever showed a password field, and start_bridge errored with "No config found" when nothing was configured yet, so a brand-new user could never get past the start screen. Now the dashboard shows a Tuta email field too when no account is set up, and start_bridge bootstraps the config from that email (with defaults) instead of failing. Once an account exists the email field disappears and only the password is asked (until a keyring session is saved).
This commit is contained in:
@@ -42,12 +42,26 @@ pub async fn has_saved_session() -> Result<bool, String> {
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn start_bridge(
|
||||
email: Option<String>,
|
||||
password: Option<String>,
|
||||
state: State<'_, BridgeState>,
|
||||
) -> Result<(), String> {
|
||||
let mut cfg = match config::load_config() {
|
||||
Ok(Some(cfg)) if !cfg.email.is_empty() => cfg,
|
||||
_ => return Err("No config found — save config first".into()),
|
||||
// First run: no account yet. Bootstrap a default config from the email
|
||||
// the user just entered on the dashboard, instead of erroring out.
|
||||
_ => {
|
||||
let email = email.unwrap_or_default().trim().to_string();
|
||||
if email.is_empty() {
|
||||
return Err("Enter your Tuta email to get started".into());
|
||||
}
|
||||
let cfg = Config {
|
||||
email,
|
||||
..Default::default()
|
||||
};
|
||||
config::save_config(&cfg).map_err(|e| format!("Failed to save config: {e}"))?;
|
||||
cfg
|
||||
}
|
||||
};
|
||||
|
||||
config::ensure_bridge_password(&mut cfg)
|
||||
|
||||
Reference in New Issue
Block a user