recalc stats on spec remove

This commit is contained in:
ntr 2019-02-16 11:07:47 +11:00
parent a822177fb8
commit 8f12075d52

View File

@ -306,7 +306,7 @@ impl Cryp {
return Ok(self.recalculate_stats()); return Ok(self.recalculate_stats());
} }
pub fn spec_remove(mut self, spec: Spec) -> Result<Cryp, Error> { pub fn spec_remove(&mut self, spec: Spec) -> Result<&mut Cryp, Error> {
let find_spec = |spec_v: &Vec<Spec>| spec_v.iter().position(|s| s.spec == spec.spec); let find_spec = |spec_v: &Vec<Spec>| spec_v.iter().position(|s| s.spec == spec.spec);
match spec.level { match spec.level {
@ -324,7 +324,7 @@ impl Cryp {
}, },
}; };
Ok(self) Ok(self.recalculate_stats())
} }
@ -734,7 +734,7 @@ pub fn cryp_forget(params: CrypForgetParams, tx: &mut Transaction, account: &Acc
pub fn cryp_unspec(params: CrypUnspecParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> { pub fn cryp_unspec(params: CrypUnspecParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> {
let mut cryp = cryp_get(tx, params.id, account.id)?; let mut cryp = cryp_get(tx, params.id, account.id)?;
cryp = cryp.spec_remove(params.spec)?; cryp.spec_remove(params.spec)?;
return cryp_write(cryp, tx); return cryp_write(cryp, tx);
} }