Add function to clear image cache
This commit is contained in:
@@ -54,6 +54,12 @@ struct SettingsView: View {
|
||||
SettingsStatisticRow(label: "Image cache", value: byteString(imageCacheSize))
|
||||
SettingsStatisticRow(label: "Database", value: byteString(database.databaseSize))
|
||||
SettingsStatisticRow(label: "Classifier", value: byteString(database.classifierSize))
|
||||
HStack {
|
||||
Spacer()
|
||||
Button("Clear image cache", action: clearImageCache)
|
||||
.padding()
|
||||
Spacer()
|
||||
}
|
||||
}.padding(.horizontal)
|
||||
Spacer()
|
||||
}
|
||||
@@ -64,8 +70,15 @@ struct SettingsView: View {
|
||||
}
|
||||
|
||||
private func updateImageCacheSize() {
|
||||
imageCacheSize = database.imageCacheSize()
|
||||
}
|
||||
|
||||
private func clearImageCache() {
|
||||
Task {
|
||||
imageCacheSize = await database.imageCacheSize()
|
||||
database.clearImageCache()
|
||||
DispatchQueue.main.async {
|
||||
updateImageCacheSize()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user