Fix backup loop, phone count invariant, and auto-start behaviour

- LocalPhotoIndex: add count(filter:) so fast-path reconcile uses the
  filtered asset count as phoneTotal instead of the unfiltered totalCount;
  fixes the broken alreadySafe + needBackup == phoneTotal invariant

- BackupStatusService: fast-path uses count(filter:) instead of totalCount;
  writeManifest falls back to NASManifestCache when NAS download fails so
  accumulated history is never silently discarded on a flaky connection

- ConnectionStore: autoBackupEnabled defaults false; new autoBackupOnOpen
  (default false) separates LAN-join auto-backup from app-open auto-backup

- AutoBackupCoordinator: onActive(lanTriggered:) tracks trigger source;
  handleReconciliationComplete gates on autoBackupEnabled for LAN joins and
  autoBackupOnOpen for app-open — prevents backup starting on every launch

- SettingsView: split auto-backup into two toggles with accurate descriptions

Co-Authored-By: Kutesir <kutesir@provoc.ug>
Co-Authored-By: Sentry <sentry@provoc.ug>
This commit is contained in:
Robin Kutesa
2026-05-18 10:01:09 +03:00
parent b18a2aad14
commit 3beea88fab
5 changed files with 61 additions and 22 deletions

View File

@@ -50,11 +50,18 @@ struct SettingsView: View {
VStack(spacing: 0) {
ToggleRow(
icon: "arrow.clockwise.icloud",
title: "Auto backup",
subtitle: "Back up new photos automatically when the app opens",
icon: "wifi",
title: "Auto-backup on home network",
subtitle: "Start backup automatically when joining a trusted Wi-Fi network",
isOn: $store.autoBackupEnabled
)
Divider().padding(.leading, 52)
ToggleRow(
icon: "arrow.clockwise.icloud",
title: "Auto-backup on app open",
subtitle: "Start backup every time the app is opened (off by default)",
isOn: $store.autoBackupOnOpen
)
}
.background(AppTheme.surfaceRaised)
.clipShape(RoundedRectangle(cornerRadius: AppTheme.radius, style: .continuous))