Small feature changes and bug fixes
This commit is contained in:
@@ -363,6 +363,36 @@ class GitSyncService {
|
||||
|
||||
// MARK: - Auto-Sync
|
||||
|
||||
/// Sync on app startup (pull + import only, no push)
|
||||
/// Runs silently in background to fetch changes from other devices
|
||||
func syncOnStartup() async {
|
||||
// Only run if configured and cloned
|
||||
guard settings.syncConfigured && syncStatus.isCloned else {
|
||||
log.debug("Skipping startup sync (not configured or not cloned)")
|
||||
return
|
||||
}
|
||||
|
||||
log.info("Running startup sync (pull + import)...")
|
||||
|
||||
do {
|
||||
// Pull latest changes
|
||||
try await pull()
|
||||
|
||||
// Import any new/updated conversations
|
||||
let result = try await importAllConversations()
|
||||
|
||||
if result.imported > 0 {
|
||||
log.info("Startup sync: imported \(result.imported) conversations")
|
||||
} else {
|
||||
log.debug("Startup sync: no new conversations to import")
|
||||
}
|
||||
|
||||
} catch {
|
||||
// Don't block app startup on sync errors
|
||||
log.warning("Startup sync failed (non-fatal): \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform auto-sync with debouncing (export + push)
|
||||
/// Debounces multiple rapid sync requests to avoid spamming git
|
||||
func autoSync() async {
|
||||
|
||||
Reference in New Issue
Block a user