diff options
| author | Kalle Lindström <karl.lindstrom@mullvad.net> | 2025-10-10 15:17:57 +0200 |
|---|---|---|
| committer | Kalle Lindström <karl.lindstrom@mullvad.net> | 2025-10-14 10:23:50 +0200 |
| commit | 07f02460bd7be180a55d3a8e206ed7947857dc70 (patch) | |
| tree | 3a79c11a7aa52d969ded46660604f05a1ca2b7c1 | |
| parent | f42d910066eeacf5822e09a8a77dabd7f39f0beb (diff) | |
| download | mullvadvpn-07f02460bd7be180a55d3a8e206ed7947857dc70.tar.xz mullvadvpn-07f02460bd7be180a55d3a8e206ed7947857dc70.zip | |
Show recent in all cases when recents enabled
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 16 | ||||
| -rw-r--r-- | mullvad-types/src/settings/mod.rs | 8 |
2 files changed, 19 insertions, 5 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 5783baef4e..d50e32480a 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -1575,6 +1575,7 @@ impl Daemon { log::debug!("Initiating tunnel restart because the account number changed"); self.reconnect_tunnel(); } + self.update_recents().await; } AccountEvent::Device(PrivateDeviceEvent::Logout) => { log::info!("Disconnecting because account number was cleared"); @@ -2397,6 +2398,7 @@ impl Daemon { e.display_chain_with_msg("Unable to save has_updated_default_country") ); } + self.update_recents().await; } async fn on_set_allow_lan(&mut self, tx: ResponseTx<(), settings::Error>, allow_lan: bool) { @@ -2655,6 +2657,7 @@ impl Daemon { .update(|settings| match settings.recents { None if enable_recents => { settings.recents = Some(vec![]); + settings.update_recents(); } Some(_) if !enable_recents => { settings.recents = None; @@ -3520,6 +3523,19 @@ impl Daemon { tx: self.tx.clone(), } } + + async fn update_recents(&mut self) { + if let Err(e) = self + .settings + .update(move |settings| settings.update_recents()) + .await + { + log::error!( + "{}", + e.display_chain_with_msg("Unable to save recents to settings") + ); + } + } } #[derive(Clone)] diff --git a/mullvad-types/src/settings/mod.rs b/mullvad-types/src/settings/mod.rs index 1263089d8f..7b4f97f891 100644 --- a/mullvad-types/src/settings/mod.rs +++ b/mullvad-types/src/settings/mod.rs @@ -295,8 +295,6 @@ impl Settings { } pub fn set_relay_settings(&mut self, new_settings: RelaySettings) { - self.update_recents(&new_settings); - if self.relay_settings != new_settings { if !new_settings.supports_bridge() && BridgeState::On == self.bridge_state { self.bridge_state = BridgeState::Auto; @@ -337,16 +335,16 @@ impl Settings { } // Add the current RelaySettings to the recents list. If recents are disabled do nothing. - fn update_recents(&mut self, relay_settings: &RelaySettings) { + pub fn update_recents(&mut self) { if let Some(recents) = self.recents.as_mut() { - match Recent::try_from(relay_settings) { + match Recent::try_from(&self.relay_settings) { Ok(new_recent) => { recents.retain(|r| *r != new_recent); recents.insert(0, new_recent); recents.truncate(Self::RECENTS_MAX_COUNT); } Err(e) => { - log::debug!("Failed to convert {relay_settings:?} to recent: {e}"); + log::debug!("Failed to convert {:?} to recent: {e}", recents); } } } |
