1.6.0 #9: auto-backup programado a iCloud Drive/Archivos
El BackupService (export JSON v3 lossless a local + iCloud ubiquity, retención, restore, premium-gated) ya existía de 1.1.0 pero solo era manual. Añadido lo automático: - BackupService.runScheduledBackupIfNeeded() (config vía UserDefaults, gate por backupsEnabled+premium, respeta frecuencia). - Disparo en foreground (scenePhase .active) en background queue. - Frecuencia Off/Diario/Semanal/Mensual + fecha del último backup en Settings (SettingsViewModel.autoBackupFrequencyDays + updateAutoBackupFrequency). - Strings en 7 idiomas. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L2p3gUZRNWW388rWFRjiU7
This commit is contained in:
@@ -36,6 +36,8 @@ class SettingsViewModel: ObservableObject {
|
||||
@Published var backupRetentionCount = 10
|
||||
@Published var backups: [BackupRecord] = []
|
||||
@Published var backupsEnabled = false
|
||||
/// Auto-backup cadence in days: 0 = off, 1 = daily, 7 = weekly, 30 = monthly.
|
||||
@Published var autoBackupFrequencyDays = 0
|
||||
|
||||
// MARK: - Dependencies
|
||||
|
||||
@@ -96,6 +98,7 @@ class SettingsViewModel: ObservableObject {
|
||||
inputMode = InputMode(rawValue: settings.inputMode) ?? .simple
|
||||
backupRetentionCount = loadBackupRetention()
|
||||
backupsEnabled = loadBackupsEnabled()
|
||||
autoBackupFrequencyDays = UserDefaults.standard.integer(forKey: "autoBackupFrequencyDays")
|
||||
if backupsEnabled {
|
||||
refreshBackups()
|
||||
} else {
|
||||
@@ -395,6 +398,19 @@ class SettingsViewModel: ObservableObject {
|
||||
backups = BackupService.shared.listAllBackups(includeICloud: includeICloud)
|
||||
}
|
||||
|
||||
/// Auto-backup cadence (0 = off). Running one immediately when enabled gives
|
||||
/// instant feedback that it works.
|
||||
func updateAutoBackupFrequency(_ days: Int) {
|
||||
guard backupsEnabled, isPremium else { return }
|
||||
autoBackupFrequencyDays = days
|
||||
UserDefaults.standard.set(days, forKey: "autoBackupFrequencyDays")
|
||||
if days > 0 { createBackupNow() }
|
||||
}
|
||||
|
||||
var lastAutoBackupDate: Date? {
|
||||
UserDefaults.standard.object(forKey: "lastAutoBackupDate") as? Date
|
||||
}
|
||||
|
||||
func createBackupNow() {
|
||||
guard backupsEnabled, isPremium else { return }
|
||||
guard !isBackupInProgress else { return }
|
||||
|
||||
Reference in New Issue
Block a user