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
|
return caps.values.filter { $0.classifiable(by: version) }.count
|
||||||
}
|
}
|
||||||
|
|
||||||
var imageCacheSize: Int {
|
func imageCacheSize() async -> Int {
|
||||||
fm.directorySize(images.folder)
|
fm.directorySize(images.folder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ struct SettingsView: View {
|
|||||||
@AppStorage("authKey")
|
@AppStorage("authKey")
|
||||||
private var serverAuthenticationKey: String = ""
|
private var serverAuthenticationKey: String = ""
|
||||||
|
|
||||||
|
@State
|
||||||
|
private var imageCacheSize: Int = 0
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
VStack(alignment: .leading, spacing: 3) {
|
VStack(alignment: .leading, spacing: 3) {
|
||||||
@ -48,7 +51,7 @@ struct SettingsView: View {
|
|||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
.padding(.top)
|
.padding(.top)
|
||||||
Group {
|
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: "Database", value: byteString(database.databaseSize))
|
||||||
SettingsStatisticRow(label: "Classifier", value: byteString(database.classifierSize))
|
SettingsStatisticRow(label: "Classifier", value: byteString(database.classifierSize))
|
||||||
}.padding(.horizontal)
|
}.padding(.horizontal)
|
||||||
@ -56,6 +59,13 @@ struct SettingsView: View {
|
|||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
.navigationTitle("Settings")
|
.navigationTitle("Settings")
|
||||||
|
.onAppear(perform: updateImageCacheSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateImageCacheSize() {
|
||||||
|
Task {
|
||||||
|
imageCacheSize = await database.imageCacheSize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user