fix(settings): red Clear Cache button, confirm when it's done

role: .destructive alone wasn't rendering red on its own — explicit
.buttonStyle(.borderedProminent).tint(.red), matching how other
destructive actions in the app (DocumentShareSheet's Revoke) had to
be styled explicitly too. Also shows a transient "Cleared" checkmark
for 2s after finishing, same timed-reset pattern as the share sheet's
copy-link feedback, since the storage count updating alone was easy
to miss.
This commit is contained in:
2026-08-15 01:01:19 +01:00
parent d4d81bb848
commit 1ce2aced90
+14 -1
View File
@@ -21,6 +21,7 @@ struct SettingsView: View {
@State private var pendingOperations: [PendingOperationSummary] = []
@State private var isSyncing = false
@State private var isClearingCache = false
@State private var didClearCache = false
@State private var lastFullSyncSummary: FullSyncSummary?
@State private var lastFlushSummary: SyncFlushSummary?
@@ -288,9 +289,14 @@ struct SettingsView: View {
.frame(maxWidth: 480)
VStack(alignment: .leading, spacing: 6) {
HStack {
HStack(spacing: 10) {
Text("Clear All Cache")
Spacer()
if didClearCache {
Label("Cleared", systemImage: "checkmark")
.font(.caption)
.foregroundStyle(.secondary)
}
Button(role: .destructive) {
Task { await clearCache() }
} label: {
@@ -300,6 +306,8 @@ struct SettingsView: View {
Text("Clear")
}
}
.buttonStyle(.borderedProminent)
.tint(.red)
}
Text("Deletes every cached collection and document, including anything Full Local Sync built, and anything still waiting to sync. Doesn't touch the server. This is the only place that can — it works even while offline, which is exactly why it's behind this toggle.")
.font(.caption2)
@@ -410,6 +418,11 @@ struct SettingsView: View {
defer { isClearingCache = false }
await cachingClient.clearCache()
await refreshSyncState()
didClearCache = true
Task {
try? await Task.sleep(for: .seconds(2))
didClearCache = false
}
}
}
#endif