Skip to content

Commit

Permalink
Fix sidebar selection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lbrndnr committed Jul 29, 2023
1 parent aff0a11 commit dab48a4
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions Nuage/Views/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,32 +102,36 @@ struct MainView: View {
}

@ViewBuilder private func root(for item: SidebarItem) -> some View {
switch item {
case .stream:
let stream = SoundCloud.shared.get(.stream())
PostList(for: stream).navigationTitle(item.title)
case .likes:
let likes = SoundCloud.shared.$user.filter { $0 != nil}
.flatMap { SoundCloud.shared.get(.trackLikes(of: $0!)) }
.eraseToAnyPublisher()
TrackList(for: likes).navigationTitle(item.title)
case .history:
let history = SoundCloud.shared.get(.history())
TrackList(for: history).navigationTitle(item.title)
case .following:
let following = SoundCloud.shared.$user.filter { $0 != nil }
.flatMap { SoundCloud.shared.get(.followings(of: $0!)) }
.eraseToAnyPublisher()
UserGrid(for: following).navigationTitle(item.title)
case .playlist(_, let id):
let ids = SoundCloud.shared.get(.playlist(id))
.map { $0.trackIDs ?? [] }
.eraseToAnyPublisher()
let slice = { ids in
return SoundCloud.shared.get(.tracks(ids))
Group {
switch item {
case .stream:
let stream = SoundCloud.shared.get(.stream())
PostList(for: stream)
case .likes:
let likes = SoundCloud.shared.$user.filter { $0 != nil}
.flatMap { SoundCloud.shared.get(.trackLikes(of: $0!)) }
.eraseToAnyPublisher()
TrackList(for: likes)
case .history:
let history = SoundCloud.shared.get(.history())
TrackList(for: history)
case .following:
let following = SoundCloud.shared.$user.filter { $0 != nil }
.flatMap { SoundCloud.shared.get(.followings(of: $0!)) }
.eraseToAnyPublisher()
UserGrid(for: following)
case .playlist(_, let id):
let ids = SoundCloud.shared.get(.playlist(id))
.map { $0.trackIDs ?? [] }
.eraseToAnyPublisher()
let slice = { ids in
return SoundCloud.shared.get(.tracks(ids))
}
TrackList(for: ids, slice: slice)
}
TrackList(for: ids, slice: slice).navigationTitle(item.title)
}
.navigationTitle(item.title)
.id(item.id)
}

@ViewBuilder private func navigationDestination<T: SoundCloudIdentifiable>(for element: T) -> some View {
Expand Down

0 comments on commit dab48a4

Please sign in to comment.