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 pendingOperations: [PendingOperationSummary] = []
@State private var isSyncing = false @State private var isSyncing = false
@State private var isClearingCache = false @State private var isClearingCache = false
@State private var didClearCache = false
@State private var lastFullSyncSummary: FullSyncSummary? @State private var lastFullSyncSummary: FullSyncSummary?
@State private var lastFlushSummary: SyncFlushSummary? @State private var lastFlushSummary: SyncFlushSummary?
@@ -288,9 +289,14 @@ struct SettingsView: View {
.frame(maxWidth: 480) .frame(maxWidth: 480)
VStack(alignment: .leading, spacing: 6) { VStack(alignment: .leading, spacing: 6) {
HStack { HStack(spacing: 10) {
Text("Clear All Cache") Text("Clear All Cache")
Spacer() Spacer()
if didClearCache {
Label("Cleared", systemImage: "checkmark")
.font(.caption)
.foregroundStyle(.secondary)
}
Button(role: .destructive) { Button(role: .destructive) {
Task { await clearCache() } Task { await clearCache() }
} label: { } label: {
@@ -300,6 +306,8 @@ struct SettingsView: View {
Text("Clear") 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.") 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) .font(.caption2)
@@ -410,6 +418,11 @@ struct SettingsView: View {
defer { isClearingCache = false } defer { isClearingCache = false }
await cachingClient.clearCache() await cachingClient.clearCache()
await refreshSyncState() await refreshSyncState()
didClearCache = true
Task {
try? await Task.sleep(for: .seconds(2))
didClearCache = false
}
} }
} }
#endif #endif