mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Fix clear history, add clear cache
This commit is contained in:
parent
4d94126abd
commit
4a26ef2839
@ -22,4 +22,9 @@ struct CacheModel {
|
||||
let jsonTransformer = Transformer<JSON>(toData: toData, fromData: fromData)
|
||||
videoStorage = try? Storage<Video.ID, JSON>(diskConfig: videoStorageConfig, memoryConfig: videoStorageMemoryConfig, transformer: jsonTransformer)
|
||||
}
|
||||
|
||||
func removeAll() {
|
||||
try? videoStorage?.removeAll()
|
||||
try? urlBookmarksStorage?.removeAll()
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ import SwiftUI
|
||||
struct HistorySettings: View {
|
||||
static let watchedThresholds = [50, 60, 70, 80, 90, 95, 100]
|
||||
|
||||
@State private var presentingClearHistoryConfirmation = false
|
||||
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
@EnvironmentObject<SettingsModel> private var settings
|
||||
|
||||
@Default(.saveRecents) private var saveRecents
|
||||
@Default(.saveLastPlayed) private var saveLastPlayed
|
||||
@ -143,25 +142,26 @@ struct HistorySettings: View {
|
||||
}
|
||||
|
||||
private var clearHistoryButton: some View {
|
||||
Button("Clear History") {
|
||||
presentingClearHistoryConfirmation = true
|
||||
}
|
||||
.alert(isPresented: $presentingClearHistoryConfirmation) {
|
||||
Alert(
|
||||
title: Text(
|
||||
"Are you sure you want to clear history of watched videos?"
|
||||
),
|
||||
message: Text(
|
||||
"This cannot be reverted. You might need to switch between views or restart the app to see changes."
|
||||
),
|
||||
primaryButton: .destructive(Text("Clear All")) {
|
||||
player.removeAllWatches()
|
||||
presentingClearHistoryConfirmation = false
|
||||
},
|
||||
secondaryButton: .cancel()
|
||||
Button {
|
||||
settings.presentAlert(
|
||||
Alert(
|
||||
title: Text(
|
||||
"Are you sure you want to clear history of watched videos?"
|
||||
),
|
||||
message: Text(
|
||||
"This cannot be reverted. You might need to switch between views or restart the app to see changes."
|
||||
),
|
||||
primaryButton: .destructive(Text("Clear All")) {
|
||||
player.removeAllWatches()
|
||||
CacheModel.shared.removeAll()
|
||||
},
|
||||
secondaryButton: .cancel()
|
||||
)
|
||||
)
|
||||
} label: {
|
||||
Text("Clear History")
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user