Cache settings

This commit is contained in:
Arkadiusz Fal
2022-12-13 12:09:20 +01:00
parent 8f2b570163
commit e4d583a263
6 changed files with 69 additions and 22 deletions

View File

@@ -6,8 +6,8 @@ struct AdvancedSettings: View {
@Default(.mpvCacheSecs) private var mpvCacheSecs
@Default(.mpvCachePauseWait) private var mpvCachePauseWait
@Default(.mpvEnableLogging) private var mpvEnableLogging
@Default(.countryOfPublicInstances) private var countryOfPublicInstances
@Default(.instances) private var instances
@Default(.showCacheStatus) private var showCacheStatus
@Default(.feedCacheSize) private var feedCacheSize
@State private var countries = [String]()
@State private var filesToShare = [MPVClient.logFile]
@@ -33,9 +33,6 @@ struct AdvancedSettings: View {
#endif
#endif
}
.onChange(of: countryOfPublicInstances) { newCountry in
InstancesManifest.shared.setPublicAccount(newCountry, asCurrent: AccountsModel.shared.current?.isPublic ?? true)
}
#if os(tvOS)
.frame(maxWidth: 1000)
#endif
@@ -85,9 +82,10 @@ struct AdvancedSettings: View {
}
}
Section(header: SettingsHeader(text: "Cache")) {
Section(header: SettingsHeader(text: "Cache"), footer: cacheSize) {
showCacheStatusToggle
feedCacheSizeTextField
clearCacheButton
cacheSize
}
}
@@ -130,6 +128,22 @@ struct AdvancedSettings: View {
}
#endif
private var feedCacheSizeTextField: some View {
HStack {
Text("Maximum feed items")
.frame(minWidth: 200, alignment: .leading)
TextField("Limit", text: $feedCacheSize)
#if !os(macOS)
.keyboardType(.numberPad)
#endif
}
.multilineTextAlignment(.trailing)
}
private var showCacheStatusToggle: some View {
Toggle("Show cache status", isOn: $showCacheStatus)
}
private var clearCacheButton: some View {
Button {
settings.presentAlert(