return old status on change

This commit is contained in:
yggverse 2026-03-28 04:50:13 +02:00
parent b93c1e8481
commit abeeae2f16
2 changed files with 4 additions and 2 deletions

View file

@ -41,7 +41,7 @@ async fn api_list_disable(
alias: &str, alias: &str,
rules: &State<Arc<RwLock<Rules>>>, rules: &State<Arc<RwLock<Rules>>>,
) -> Result<Json<bool>, Status> { ) -> Result<Json<bool>, Status> {
Ok(Json(rules.write().await.set_status(alias, false))) Ok(Json(!rules.write().await.set_status(alias, false)))
} }
#[rocket::launch] #[rocket::launch]

View file

@ -34,8 +34,10 @@ impl List {
}) })
} }
/// Change rule set status by list ID /// Change rule set status by list ID
pub fn set_status(&mut self, is_enabled: bool) { pub fn set_status(&mut self, is_enabled: bool) -> bool {
let was_enabled = self.is_enabled;
self.is_enabled = is_enabled; self.is_enabled = is_enabled;
was_enabled
} }
/// Check if rule is exist in the items index /// Check if rule is exist in the items index
pub fn contains(&self, value: &str) -> bool { pub fn contains(&self, value: &str) -> bool {