mirror of
https://codeberg.org/YGGverse/psocks.git
synced 2026-03-31 08:25:27 +00:00
return old status on change
This commit is contained in:
parent
b93c1e8481
commit
abeeae2f16
2 changed files with 4 additions and 2 deletions
|
|
@ -41,7 +41,7 @@ async fn api_list_disable(
|
|||
alias: &str,
|
||||
rules: &State<Arc<RwLock<Rules>>>,
|
||||
) -> Result<Json<bool>, Status> {
|
||||
Ok(Json(rules.write().await.set_status(alias, false)))
|
||||
Ok(Json(!rules.write().await.set_status(alias, false)))
|
||||
}
|
||||
|
||||
#[rocket::launch]
|
||||
|
|
|
|||
|
|
@ -34,8 +34,10 @@ impl List {
|
|||
})
|
||||
}
|
||||
/// 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;
|
||||
was_enabled
|
||||
}
|
||||
/// Check if rule is exist in the items index
|
||||
pub fn contains(&self, value: &str) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue