Add toggle for dislikes

This commit is contained in:
Arkadiusz Fal 2022-03-20 21:31:19 +01:00
parent b6a7f3886d
commit 180bace38c
5 changed files with 16 additions and 3 deletions

View File

@ -226,6 +226,10 @@ final class PlayerModel: ObservableObject {
}
}
guard Defaults[.enableReturnYouTubeDislike] else {
return
}
self?.returnYouTubeDislike.loadDislikes(videoID: video.videoID) { [weak self] dislikes in
self?.currentItem?.video?.dislikes = dislikes
}

View File

@ -23,6 +23,8 @@ extension Defaults.Keys {
static let sponsorBlockInstance = Key<String>("sponsorBlockInstance", default: "https://sponsor.ajay.app")
static let sponsorBlockCategories = Key<Set<String>>("sponsorBlockCategories", default: Set(SponsorBlockAPI.categories))
static let enableReturnYouTubeDislike = Key<Bool>("enableReturnYouTubeDislike", default: false)
static let favorites = Key<[FavoriteItem]>("favorites", default: [
.init(section: .trending("US", "default")),
.init(section: .trending("GB", "default")),

View File

@ -27,6 +27,8 @@ struct PlayerSettings: View {
@Default(.closePiPAndOpenPlayerOnEnteringForeground) private var closePiPAndOpenPlayerOnEnteringForeground
#endif
@Default(.enableReturnYouTubeDislike) private var enableReturnYouTubeDislike
#if os(iOS)
private var idiom: UIUserInterfaceIdiom {
UIDevice.current.userInterfaceIdiom
@ -82,6 +84,7 @@ struct PlayerSettings: View {
keywordsToggle
showHistoryToggle
returnYouTubeDislikeToggle
}
Section(header: SettingsHeader(text: "Picture in Picture")) {
@ -194,6 +197,10 @@ struct PlayerSettings: View {
Toggle("Show history", isOn: $showHistory)
}
private var returnYouTubeDislikeToggle: some View {
Toggle("Enable Return YouTube Dislike", isOn: $enableReturnYouTubeDislike)
}
private var pauseOnHidingPlayerToggle: some View {
Toggle("Pause when player is closed", isOn: $pauseOnHidingPlayer)
}

View File

@ -179,7 +179,7 @@ struct SettingsView: View {
case .browsing:
return 350
case .player:
return 450
return 470
case .history:
return 480
case .sponsorBlock:

View File

@ -23,6 +23,8 @@ import SwiftUI
@EnvironmentObject<PlayerModel> private var player
func makeNSView(context _: Context) -> some NSView {
player.mpvBackend.client = client
client.layer = layer
layer.client = client
@ -31,8 +33,6 @@ import SwiftUI
view.layer = client.layer
view.wantsLayer = true
player.mpvBackend.client = client
return view
}