feat(plex): move the Discover/Browse toggle into the header
The Discover ⟷ Browse switch now sits in the header next to the library-scope pill (All / Movies / Shows), instead of on the chip row / atop the Discover surface. It's driven through a small one-way PlexViewBridge: PlexBrowse still OWNS the sub-view (useHistorySubview) and publishes its top-level view + opener to the bridge; the always-mounted Header reads it to render PlexViewToggle. A global sub-view provider was deliberately avoided — PlexBrowse's hook remounts on every plex entry and re-seeds from history (a page switch clears ?v + drops _sub), so each entry starts at the Discover root; lifting it out would let the view go stale across navigation. The toggle hides on deeper views (show/info/person/…) and on non-plex pages (bridge cleared on unmount). sortView is just SortControl now; the grid toolbar no longer carries the toggle. Verified: toggle in the header, switches discover⟷grid, hides on info + on Feed, and Feed→Plex resets to Discover (no stale view); no console errors.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import SegmentedToggle from "./SegmentedToggle";
|
||||
import { usePlexViewControls } from "./PlexViewBridge";
|
||||
|
||||
// The Discover ⟷ Browse switch, hosted in the header next to the library-scope pill (All/Movies/Shows).
|
||||
// It reflects + drives PlexBrowse's top-level sub-view through the PlexViewBridge, and hides itself on
|
||||
// the deeper views (a show/info/person page has no Discover/Browse choice).
|
||||
export default function PlexViewToggle() {
|
||||
const { t } = useTranslation();
|
||||
const ctl = usePlexViewControls();
|
||||
if (!ctl || !ctl.toggleable) return null;
|
||||
return (
|
||||
<SegmentedToggle
|
||||
size="md"
|
||||
ariaLabel={t("plex.view.label")}
|
||||
options={[
|
||||
{ value: "discover", label: t("plex.discover.tab") },
|
||||
{ value: "grid", label: t("plex.view.browse") },
|
||||
]}
|
||||
value={ctl.isDiscover ? "discover" : "grid"}
|
||||
onChange={(v) => ctl.open(v === "discover" ? { kind: "discover" } : { kind: "grid" })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user