Async update content cache size
This commit is contained in:
parent
24d09d3883
commit
228261b5e1
@ -713,7 +713,7 @@ final class Database: ObservableObject {
|
||||
return caps.values.filter { $0.classifiable(by: version) }.count
|
||||
}
|
||||
|
||||
var imageCacheSize: Int {
|
||||
func imageCacheSize() async -> Int {
|
||||
fm.directorySize(images.folder)
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,9 @@ struct SettingsView: View {
|
||||
@AppStorage("authKey")
|
||||
private var serverAuthenticationKey: String = ""
|
||||
|
||||
@State
|
||||
private var imageCacheSize: Int = 0
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
@ -48,7 +51,7 @@ struct SettingsView: View {
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.top)
|
||||
Group {
|
||||
SettingsStatisticRow(label: "Image cache", value: byteString(database.imageCacheSize))
|
||||
SettingsStatisticRow(label: "Image cache", value: byteString(imageCacheSize))
|
||||
SettingsStatisticRow(label: "Database", value: byteString(database.databaseSize))
|
||||
SettingsStatisticRow(label: "Classifier", value: byteString(database.classifierSize))
|
||||
}.padding(.horizontal)
|
||||
@ -56,6 +59,13 @@ struct SettingsView: View {
|
||||
}
|
||||
.padding(.horizontal)
|
||||
.navigationTitle("Settings")
|
||||
.onAppear(perform: updateImageCacheSize)
|
||||
}
|
||||
}
|
||||
|
||||
private func updateImageCacheSize() {
|
||||
Task {
|
||||
imageCacheSize = await database.imageCacheSize()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user