mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Add setting for saving videos history
This commit is contained in:
parent
26f672ff4f
commit
a7d9efdd9d
@ -149,7 +149,7 @@ extension PlayerModel {
|
||||
}
|
||||
|
||||
func addCurrentItemToHistory() {
|
||||
if let item = currentItem {
|
||||
if let item = currentItem, Defaults[.saveHistory] {
|
||||
addItemToHistory(item)
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ extension Defaults.Keys {
|
||||
static let history = Key<[PlayerQueueItem]>("history", default: [])
|
||||
static let lastPlayed = Key<PlayerQueueItem?>("lastPlayed")
|
||||
|
||||
static let saveHistory = Key<Bool>("saveHistory", default: true)
|
||||
|
||||
static let trendingCategory = Key<TrendingCategory>("trendingCategory", default: .default)
|
||||
static let trendingCountry = Key<Country>("trendingCountry", default: .us)
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import Defaults
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
@ -7,6 +8,8 @@ struct PlayerQueueView: View {
|
||||
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
|
||||
@Default(.saveHistory) private var saveHistory
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Group {
|
||||
@ -14,8 +17,10 @@ struct PlayerQueueView: View {
|
||||
if sidebarQueue {
|
||||
related
|
||||
}
|
||||
if saveHistory {
|
||||
playedPreviously
|
||||
}
|
||||
}
|
||||
#if !os(iOS)
|
||||
.padding(.vertical, 5)
|
||||
.listRowInsets(EdgeInsets())
|
||||
|
@ -105,7 +105,7 @@ struct VideoDetails: View {
|
||||
}
|
||||
.padding(.top, inNavigationView && fullScreen ? 10 : 0)
|
||||
.onAppear {
|
||||
if video.isNil {
|
||||
if video.isNil && !sidebarQueue {
|
||||
currentPage = .queue
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ struct PlaybackSettings: View {
|
||||
@Default(.quality) private var quality
|
||||
@Default(.playerSidebar) private var playerSidebar
|
||||
@Default(.showKeywords) private var showKeywords
|
||||
@Default(.saveHistory) private var saveHistory
|
||||
|
||||
#if os(iOS)
|
||||
private var idiom: UIUserInterfaceIdiom {
|
||||
@ -20,10 +21,13 @@ struct PlaybackSettings: View {
|
||||
Section(header: SettingsHeader(text: "Player")) {
|
||||
sourcePicker
|
||||
qualityPicker
|
||||
|
||||
if idiom == .pad {
|
||||
sidebarPicker
|
||||
}
|
||||
|
||||
keywordsToggle
|
||||
saveHistoryToggle
|
||||
}
|
||||
#else
|
||||
Section(header: SettingsHeader(text: "Source")) {
|
||||
@ -41,6 +45,7 @@ struct PlaybackSettings: View {
|
||||
#endif
|
||||
|
||||
keywordsToggle
|
||||
saveHistoryToggle
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -104,6 +109,10 @@ struct PlaybackSettings: View {
|
||||
private var keywordsToggle: some View {
|
||||
Toggle("Show video keywords", isOn: $showKeywords)
|
||||
}
|
||||
|
||||
private var saveHistoryToggle: some View {
|
||||
Toggle("Save history of played videos", isOn: $saveHistory)
|
||||
}
|
||||
}
|
||||
|
||||
struct PlaybackSettings_Previews: PreviewProvider {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct NowPlayingView: View {
|
||||
@ -10,6 +11,8 @@ struct NowPlayingView: View {
|
||||
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
|
||||
@Default(.saveHistory) private var saveHistory
|
||||
|
||||
var body: some View {
|
||||
if inInfoViewController {
|
||||
content
|
||||
@ -80,7 +83,7 @@ struct NowPlayingView: View {
|
||||
}
|
||||
}
|
||||
|
||||
if sections.contains(.playedPreviously), !player.history.isEmpty {
|
||||
if sections.contains(.playedPreviously), saveHistory, !player.history.isEmpty {
|
||||
Section(header: Text("Played Previously")) {
|
||||
ForEach(player.history) { item in
|
||||
Button {
|
||||
|
Loading…
Reference in New Issue
Block a user