mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 18:54:11 +00:00
Recently opened for sidebar navigation
This commit is contained in:
@@ -3,13 +3,18 @@ import Siesta
|
||||
import SwiftUI
|
||||
|
||||
struct SearchView: View {
|
||||
@Default(.searchQuery) private var queryText
|
||||
@Default(.searchSortOrder) private var searchSortOrder
|
||||
@Default(.searchDate) private var searchDate
|
||||
@Default(.searchDuration) private var searchDuration
|
||||
|
||||
@EnvironmentObject<SearchState> private var state
|
||||
|
||||
private var query: SearchQuery?
|
||||
|
||||
init(_ query: SearchQuery? = nil) {
|
||||
self.query = query
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
VideosView(videos: state.store.collection)
|
||||
@@ -27,11 +32,8 @@ struct SearchView: View {
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
state.changeQuery { query in
|
||||
query.query = queryText
|
||||
query.sortBy = searchSortOrder
|
||||
query.date = searchDate
|
||||
query.duration = searchDuration
|
||||
if query != nil {
|
||||
state.resetQuery(query!)
|
||||
}
|
||||
}
|
||||
.onChange(of: state.query.query) { queryText in
|
||||
|
@@ -3,6 +3,7 @@ import SwiftUI
|
||||
|
||||
struct VideoContextMenuView: View {
|
||||
@EnvironmentObject<NavigationState> private var navigationState
|
||||
@EnvironmentObject<Recents> private var recents
|
||||
@EnvironmentObject<Subscriptions> private var subscriptions
|
||||
|
||||
let video: Video
|
||||
@@ -14,15 +15,11 @@ struct VideoContextMenuView: View {
|
||||
|
||||
var body: some View {
|
||||
Section {
|
||||
if navigationState.showOpenChannel(video.channel.id) {
|
||||
openChannelButton
|
||||
}
|
||||
openChannelButton
|
||||
|
||||
subscriptionButton
|
||||
.opacity(subscribed ? 1 : 1)
|
||||
|
||||
openVideoDetailsButton
|
||||
|
||||
if navigationState.tabSelection == .playlists {
|
||||
removeFromPlaylistButton
|
||||
} else {
|
||||
@@ -33,8 +30,10 @@ struct VideoContextMenuView: View {
|
||||
|
||||
var openChannelButton: some View {
|
||||
Button("\(video.author) Channel") {
|
||||
navigationState.openChannel(video.channel)
|
||||
navigationState.tabSelection = .channel(video.channel.id)
|
||||
let recent = RecentItem(from: video.channel)
|
||||
recents.open(recent)
|
||||
navigationState.tabSelection = .recentlyOpened(recent.tag)
|
||||
navigationState.isChannelOpen = true
|
||||
navigationState.sidebarSectionChanged.toggle()
|
||||
}
|
||||
}
|
||||
@@ -59,12 +58,6 @@ struct VideoContextMenuView: View {
|
||||
}
|
||||
}
|
||||
|
||||
var openVideoDetailsButton: some View {
|
||||
Button("Open video details") {
|
||||
navigationState.openVideoDetails(video)
|
||||
}
|
||||
}
|
||||
|
||||
var addToPlaylistButton: some View {
|
||||
Button("Add to playlist...") {
|
||||
videoIDToAddToPlaylist = video.id
|
||||
|
Reference in New Issue
Block a user