Cancel auto save on save (#1859)

pull/1807/head
Tony 8 months ago committed by GitHub
parent f12d35609a
commit 7e5e34420b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -437,6 +437,9 @@ impl<R: Runtime> Store<R> {
}
pub fn save(&self) -> crate::Result<()> {
if let Some(sender) = self.auto_save_debounce_sender.lock().unwrap().take() {
let _ = sender.send(AutoSaveMessage::Cancel);
}
self.store.lock().unwrap().save(self.serialize)
}
@ -467,8 +470,8 @@ impl<R: Runtime> Store<R> {
}
}
_ = sleep(auto_save_delay) => {
let _ = store.lock().unwrap().save(serialize_fn);
auto_save_debounce_sender.lock().unwrap().take();
let _ = store.lock().unwrap().save(serialize_fn);
return;
}
};
@ -477,12 +480,3 @@ impl<R: Runtime> Store<R> {
Ok(())
}
}
impl<R: Runtime> Drop for Store<R> {
fn drop(&mut self) {
let auto_save_debounce_sender = self.auto_save_debounce_sender.lock().unwrap();
if let Some(ref sender) = *auto_save_debounce_sender {
let _ = sender.send(AutoSaveMessage::Cancel);
}
}
}

Loading…
Cancel
Save