refactor: enhance sync module with report tracking, payload parsing, and IndexMap support

This commit is contained in:
2026-06-05 17:15:18 +08:00
parent d88f0843b5
commit 8e6d732122
14 changed files with 412 additions and 215 deletions
+4 -15
View File
@@ -63,24 +63,13 @@ impl App {
Ok(())
}
pub fn push_sync_with_toast(&mut self) {
pub fn sync_with_toast(&mut self) {
let result = match self.config.settings.backend {
SyncBackend::Gist => crate::sync::gist::push(&mut self.config).map(|id| format!("pushed ({id})")),
SyncBackend::Webdav => crate::sync::webdav::push(&mut self.config).map(|_| "pushed".to_string()),
SyncBackend::Gist => crate::sync::gist::sync(&mut self.config),
SyncBackend::Webdav => crate::sync::webdav::sync(&mut self.config),
};
match result {
Ok(msg) => self.toast(msg, true),
Err(err) => self.toast(err.to_string(), false),
}
}
pub fn pull_sync_with_toast(&mut self) {
let result = match self.config.settings.backend {
SyncBackend::Gist => crate::sync::gist::pull_with_strategy(&mut self.config, crate::sync::PullStrategy::Merge),
SyncBackend::Webdav => crate::sync::webdav::pull_with_strategy(&mut self.config, crate::sync::PullStrategy::Merge),
};
match result {
Ok(count) => self.toast(format!("pulled {count} items"), true),
Ok(report) => self.toast(report.to_string(), true),
Err(err) => self.toast(err.to_string(), false),
}
}