mirror of
https://github.com/yattee/yattee.git
synced 2026-10-23 13:12:53 +00:00
Return to Home when the selected sidebar source is removed
This commit is contained in:
@@ -114,6 +114,9 @@ struct UnifiedTabView: View {
|
||||
.onChange(of: router.selection) { _, _ in
|
||||
ensureSelectionIsAvailable(visibleMainItems: visibleMainItems)
|
||||
}
|
||||
.onChange(of: sidebarManager.sortedSourceItems) { _, items in
|
||||
leaveRemovedSource(remaining: items)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@@ -391,6 +394,9 @@ struct UnifiedTabView: View {
|
||||
// detail visible until the user manually presses Menu.
|
||||
NotificationCenter.default.post(name: .yatteeTVForcePopDetail, object: nil)
|
||||
}
|
||||
.onChange(of: sidebarManager.sortedSourceItems) { _, items in
|
||||
leaveRemovedSource(remaining: items)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Visible Main Items
|
||||
@@ -652,6 +658,16 @@ extension UnifiedTabView {
|
||||
)
|
||||
}
|
||||
|
||||
/// A source removed (or disabled) while selected leaves its row with
|
||||
/// nothing to render, so the user lands on Home instead of a blank page.
|
||||
func leaveRemovedSource(remaining items: [SidebarItem]) {
|
||||
let current = router.selection
|
||||
guard current.isMediaSource || current.isInstance,
|
||||
!items.contains(where: { $0.id == current.id }) else { return }
|
||||
router.popToRoot(current)
|
||||
router.select(.home)
|
||||
}
|
||||
|
||||
// MARK: - Channel Content & Labels
|
||||
|
||||
@ViewBuilder
|
||||
|
||||
Reference in New Issue
Block a user