refactor(nav): read navigation from context, drop the prop-drilling
VideoCard/PlayerModal read openChannel from useNavigationActions (the memo'd VideoCard subscribes to the STABLE actions context, so a page/channel change no longer re-renders it); NavSidebar/Header read page/setPage; ChannelPage reads closeChannel; NotificationsPanel reads setPage. App sheds the matching props, and Feed/VirtualFeed no longer thread onOpenChannel at all.
This commit is contained in:
@@ -148,7 +148,7 @@ function loadInitialFilters(): FeedFilters {
|
|||||||
export default function App() {
|
export default function App() {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const { page, channelView, ytSearch } = useNavigation();
|
const { page, channelView, ytSearch } = useNavigation();
|
||||||
const { setPage, openChannel, closeChannel, enterYtSearch, exitYtSearch } = useNavigationActions();
|
const { setPage, openChannel, enterYtSearch, exitYtSearch } = useNavigationActions();
|
||||||
const [theme, setThemeState] = useState<ThemePrefs>(() => loadLocalTheme());
|
const [theme, setThemeState] = useState<ThemePrefs>(() => loadLocalTheme());
|
||||||
const [filters, setFiltersState] = useState<FeedFilters>(loadInitialFilters);
|
const [filters, setFiltersState] = useState<FeedFilters>(loadInitialFilters);
|
||||||
// Whether this load arrived via a "Share view" link (captured once, before the URL is stripped)
|
// Whether this load arrived via a "Share view" link (captured once, before the URL is stripped)
|
||||||
@@ -636,8 +636,6 @@ export default function App() {
|
|||||||
<div className="h-screen flex text-fg">
|
<div className="h-screen flex text-fg">
|
||||||
<NavSidebar
|
<NavSidebar
|
||||||
me={meQuery.data!}
|
me={meQuery.data!}
|
||||||
page={page}
|
|
||||||
setPage={setPage}
|
|
||||||
onOpenAbout={() => setAboutOpen(true)}
|
onOpenAbout={() => setAboutOpen(true)}
|
||||||
onChangeLanguage={changeLanguage}
|
onChangeLanguage={changeLanguage}
|
||||||
language={i18n.language as LangCode}
|
language={i18n.language as LangCode}
|
||||||
@@ -699,8 +697,6 @@ export default function App() {
|
|||||||
me={meQuery.data!}
|
me={meQuery.data!}
|
||||||
view={view}
|
view={view}
|
||||||
setView={setView}
|
setView={setView}
|
||||||
onBack={closeChannel}
|
|
||||||
onOpenChannel={openChannel}
|
|
||||||
onShowInFeed={() => {
|
onShowInFeed={() => {
|
||||||
// Keep the rest of the feed's filters — the point is "this channel, the way I
|
// Keep the rest of the feed's filters — the point is "this channel, the way I
|
||||||
// normally read": unwatched, my tags, my date window.
|
// normally read": unwatched, my tags, my date window.
|
||||||
@@ -730,8 +726,6 @@ export default function App() {
|
|||||||
setChannelsSearch={setChannelsSearch}
|
setChannelsSearch={setChannelsSearch}
|
||||||
playlistsSearch={playlistsSearch}
|
playlistsSearch={playlistsSearch}
|
||||||
setPlaylistsSearch={setPlaylistsSearch}
|
setPlaylistsSearch={setPlaylistsSearch}
|
||||||
page={page}
|
|
||||||
setPage={setPage}
|
|
||||||
onYtSearch={enterYtSearch}
|
onYtSearch={enterYtSearch}
|
||||||
onGoToFullHistory={() => {
|
onGoToFullHistory={() => {
|
||||||
setChannelFilter("needs_full");
|
setChannelFilter("needs_full");
|
||||||
@@ -789,7 +783,7 @@ export default function App() {
|
|||||||
setSelectedId={setSelectedPlaylistId}
|
setSelectedId={setSelectedPlaylistId}
|
||||||
/>
|
/>
|
||||||
) : page === "notifications" ? (
|
) : page === "notifications" ? (
|
||||||
<NotificationsPanel filters={filters} setFilters={setFilters} setPage={setPage} onFocusChannel={focusChannel} />
|
<NotificationsPanel filters={filters} setFilters={setFilters} onFocusChannel={focusChannel} />
|
||||||
) : page === "messages" && !meQuery.data!.is_demo ? (
|
) : page === "messages" && !meQuery.data!.is_demo ? (
|
||||||
<div className="p-4 max-w-3xl w-full mx-auto">
|
<div className="p-4 max-w-3xl w-full mx-auto">
|
||||||
<Messages meId={meQuery.data!.id} />
|
<Messages meId={meQuery.data!.id} />
|
||||||
@@ -826,7 +820,6 @@ export default function App() {
|
|||||||
ytSearch={ytSearch}
|
ytSearch={ytSearch}
|
||||||
onYtSearch={enterYtSearch}
|
onYtSearch={enterYtSearch}
|
||||||
onExitYtSearch={exitYtSearch}
|
onExitYtSearch={exitYtSearch}
|
||||||
onOpenChannel={openChannel}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useNavigationActions } from "./NavigationProvider";
|
||||||
import { ArrowLeft, Ban, Check, ExternalLink, Loader2, Plus, RefreshCw, SlidersHorizontal } from "lucide-react";
|
import { ArrowLeft, Ban, Check, ExternalLink, Loader2, Plus, RefreshCw, SlidersHorizontal } from "lucide-react";
|
||||||
import Avatar from "./Avatar";
|
import Avatar from "./Avatar";
|
||||||
import Feed from "./Feed";
|
import Feed from "./Feed";
|
||||||
@@ -57,8 +58,6 @@ export default function ChannelPage({
|
|||||||
me,
|
me,
|
||||||
view,
|
view,
|
||||||
setView,
|
setView,
|
||||||
onBack,
|
|
||||||
onOpenChannel,
|
|
||||||
onShowInFeed,
|
onShowInFeed,
|
||||||
}: {
|
}: {
|
||||||
channelId: string;
|
channelId: string;
|
||||||
@@ -68,14 +67,13 @@ export default function ChannelPage({
|
|||||||
// toolbar carries the same switcher and a change here is the same account-wide choice.
|
// toolbar carries the same switcher and a change here is the same account-wide choice.
|
||||||
view: FeedView;
|
view: FeedView;
|
||||||
setView: (v: FeedView) => void;
|
setView: (v: FeedView) => void;
|
||||||
onBack: () => void;
|
|
||||||
// Narrow the real feed to this channel and go there. Offered only for a channel you're
|
// Narrow the real feed to this channel and go there. Offered only for a channel you're
|
||||||
// subscribed to: the feed defaults to scope "my", so filtering it to a channel you don't
|
// subscribed to: the feed defaults to scope "my", so filtering it to a channel you don't
|
||||||
// follow would just land you on an empty page.
|
// follow would just land you on an empty page.
|
||||||
onShowInFeed: () => void;
|
onShowInFeed: () => void;
|
||||||
onOpenChannel: (id: string, name?: string) => void;
|
|
||||||
}) {
|
}) {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
const { closeChannel } = useNavigationActions();
|
||||||
const qc = useQueryClient();
|
const qc = useQueryClient();
|
||||||
const confirm = useConfirm();
|
const confirm = useConfirm();
|
||||||
const [tab, setTab] = useState<"videos" | "about">("videos");
|
const [tab, setTab] = useState<"videos" | "about">("videos");
|
||||||
@@ -245,7 +243,7 @@ export default function ChannelPage({
|
|||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
data-testid="channel-back"
|
data-testid="channel-back"
|
||||||
onClick={onBack}
|
onClick={closeChannel}
|
||||||
className="absolute top-5 left-7 sm:left-9 z-10 inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm bg-black/45 text-white hover:bg-black/65 backdrop-blur-sm"
|
className="absolute top-5 left-7 sm:left-9 z-10 inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm bg-black/45 text-white hover:bg-black/65 backdrop-blur-sm"
|
||||||
>
|
>
|
||||||
<ArrowLeft className="w-4 h-4" />
|
<ArrowLeft className="w-4 h-4" />
|
||||||
@@ -382,7 +380,6 @@ export default function ChannelPage({
|
|||||||
ytSearch={null}
|
ytSearch={null}
|
||||||
onYtSearch={() => {}}
|
onYtSearch={() => {}}
|
||||||
onExitYtSearch={() => {}}
|
onExitYtSearch={() => {}}
|
||||||
onOpenChannel={onOpenChannel}
|
|
||||||
channelScoped
|
channelScoped
|
||||||
/>
|
/>
|
||||||
{!ch?.subscribed && nextToken && (
|
{!ch?.subscribed && nextToken && (
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ export default function Feed({
|
|||||||
ytSearch,
|
ytSearch,
|
||||||
onYtSearch,
|
onYtSearch,
|
||||||
onExitYtSearch,
|
onExitYtSearch,
|
||||||
onOpenChannel,
|
|
||||||
channelScoped,
|
channelScoped,
|
||||||
}: {
|
}: {
|
||||||
filters: FeedFilters;
|
filters: FeedFilters;
|
||||||
@@ -107,9 +106,6 @@ export default function Feed({
|
|||||||
ytSearch: string | null;
|
ytSearch: string | null;
|
||||||
onYtSearch: (q: string) => void;
|
onYtSearch: (q: string) => void;
|
||||||
onExitYtSearch: () => void;
|
onExitYtSearch: () => void;
|
||||||
// Open a channel's dedicated page (from a card's channel name / avatar). Threaded down to
|
|
||||||
// the cards via VirtualFeed.
|
|
||||||
onOpenChannel?: (channelId: string, channelName?: string) => void;
|
|
||||||
// True when this feed is scoped to a single channel (the channel page). Drops sort options
|
// True when this feed is scoped to a single channel (the channel page). Drops sort options
|
||||||
// that are constant within one channel (subscribers, priority) — they'd be meaningless.
|
// that are constant within one channel (subscribers, priority) — they'd be meaningless.
|
||||||
channelScoped?: boolean;
|
channelScoped?: boolean;
|
||||||
@@ -308,13 +304,6 @@ export default function Feed({
|
|||||||
[qc]
|
[qc]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleOpenChannel = useCallback(
|
|
||||||
(channelId: string, channelName: string) => {
|
|
||||||
onOpenChannel?.(channelId, channelName);
|
|
||||||
},
|
|
||||||
[onOpenChannel]
|
|
||||||
);
|
|
||||||
|
|
||||||
const onToggleSave = useCallback(
|
const onToggleSave = useCallback(
|
||||||
(id: string, saved: boolean) => {
|
(id: string, saved: boolean) => {
|
||||||
setSavedOverrides((o) => ({ ...o, [id]: saved }));
|
setSavedOverrides((o) => ({ ...o, [id]: saved }));
|
||||||
@@ -447,7 +436,6 @@ export default function Feed({
|
|||||||
view={view}
|
view={view}
|
||||||
onState={onState}
|
onState={onState}
|
||||||
onToggleSave={onToggleSave}
|
onToggleSave={onToggleSave}
|
||||||
onOpenChannel={handleOpenChannel}
|
|
||||||
onResetState={onResetState}
|
onResetState={onResetState}
|
||||||
onOpen={openVideo}
|
onOpen={openVideo}
|
||||||
hasNextPage={false}
|
hasNextPage={false}
|
||||||
@@ -480,7 +468,6 @@ export default function Feed({
|
|||||||
queue={ytPlayerQueue}
|
queue={ytPlayerQueue}
|
||||||
onClose={() => setActiveVideo(null)}
|
onClose={() => setActiveVideo(null)}
|
||||||
onState={onState}
|
onState={onState}
|
||||||
onOpenChannel={onOpenChannel}
|
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)}
|
)}
|
||||||
@@ -698,7 +685,6 @@ export default function Feed({
|
|||||||
view={view}
|
view={view}
|
||||||
onState={onState}
|
onState={onState}
|
||||||
onToggleSave={onToggleSave}
|
onToggleSave={onToggleSave}
|
||||||
onOpenChannel={handleOpenChannel}
|
|
||||||
onResetState={onResetState}
|
onResetState={onResetState}
|
||||||
onOpen={openVideo}
|
onOpen={openVideo}
|
||||||
hasNextPage={!!hasNextPage}
|
hasNextPage={!!hasNextPage}
|
||||||
@@ -714,7 +700,6 @@ export default function Feed({
|
|||||||
queue={playerQueue}
|
queue={playerQueue}
|
||||||
onClose={() => setActiveVideo(null)}
|
onClose={() => setActiveVideo(null)}
|
||||||
onState={onState}
|
onState={onState}
|
||||||
onOpenChannel={onOpenChannel}
|
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { type ReactNode } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Youtube } from "lucide-react";
|
import { Youtube } from "lucide-react";
|
||||||
import type { FeedFilters, Me } from "../lib/api";
|
import type { FeedFilters, Me } from "../lib/api";
|
||||||
import type { Page } from "../lib/urlState";
|
|
||||||
import { moduleLabelKey, moduleOrder, stepModule } from "../lib/modules";
|
import { moduleLabelKey, moduleOrder, stepModule } from "../lib/modules";
|
||||||
import ModuleName from "./ModuleName";
|
import ModuleName from "./ModuleName";
|
||||||
import SearchBar from "./SearchBar";
|
import SearchBar from "./SearchBar";
|
||||||
import SyncStatus from "./SyncStatus";
|
import SyncStatus from "./SyncStatus";
|
||||||
|
import { useNavigation, useNavigationActions } from "./NavigationProvider";
|
||||||
|
|
||||||
// The floating top header: a row of glass pills over the content — a ModuleName pill (label +
|
// The floating top header: a row of glass pills over the content — a ModuleName pill (label +
|
||||||
// accent dot + back/forward arrows), the module's SearchBar where it has one, and the per-user
|
// accent dot + back/forward arrows), the module's SearchBar where it has one, and the per-user
|
||||||
@@ -21,8 +21,6 @@ export default function Header({
|
|||||||
setChannelsSearch,
|
setChannelsSearch,
|
||||||
playlistsSearch,
|
playlistsSearch,
|
||||||
setPlaylistsSearch,
|
setPlaylistsSearch,
|
||||||
page,
|
|
||||||
setPage,
|
|
||||||
onYtSearch,
|
onYtSearch,
|
||||||
onGoToFullHistory,
|
onGoToFullHistory,
|
||||||
}: {
|
}: {
|
||||||
@@ -36,8 +34,6 @@ export default function Header({
|
|||||||
setChannelsSearch: (q: string) => void;
|
setChannelsSearch: (q: string) => void;
|
||||||
playlistsSearch: string;
|
playlistsSearch: string;
|
||||||
setPlaylistsSearch: (q: string) => void;
|
setPlaylistsSearch: (q: string) => void;
|
||||||
page: Page;
|
|
||||||
setPage: (p: Page) => void;
|
|
||||||
// Trigger a live YouTube search for the current term (feed only; hidden for the demo account,
|
// Trigger a live YouTube search for the current term (feed only; hidden for the demo account,
|
||||||
// which can't spend the shared quota).
|
// which can't spend the shared quota).
|
||||||
onYtSearch: (q: string) => void;
|
onYtSearch: (q: string) => void;
|
||||||
@@ -45,6 +41,8 @@ export default function Header({
|
|||||||
onGoToFullHistory: () => void;
|
onGoToFullHistory: () => void;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { page } = useNavigation();
|
||||||
|
const { setPage } = useNavigationActions();
|
||||||
// The ◀/▶ arrows step cyclically through the user's available modules (derived from `me`, so
|
// The ◀/▶ arrows step cyclically through the user's available modules (derived from `me`, so
|
||||||
// it stays correct as modules are added/gated). Labels of every active module feed ModuleName's
|
// it stays correct as modules are added/gated). Labels of every active module feed ModuleName's
|
||||||
// dynamic width so the pill is sized to the widest reachable title in the current language.
|
// dynamic width so the pill is sized to the widest reachable title in the current language.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|||||||
import { createPortal } from "react-dom";
|
import { createPortal } from "react-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useNavigation, useNavigationActions } from "./NavigationProvider";
|
||||||
import {
|
import {
|
||||||
Activity,
|
Activity,
|
||||||
BarChart3,
|
BarChart3,
|
||||||
@@ -40,8 +41,6 @@ import LanguageSwitcher from "./LanguageSwitcher";
|
|||||||
// a thin icon-only rail. Account actions sit at the bottom in a popover.
|
// a thin icon-only rail. Account actions sit at the bottom in a popover.
|
||||||
export default function NavSidebar({
|
export default function NavSidebar({
|
||||||
me,
|
me,
|
||||||
page,
|
|
||||||
setPage,
|
|
||||||
onOpenAbout,
|
onOpenAbout,
|
||||||
onChangeLanguage,
|
onChangeLanguage,
|
||||||
language,
|
language,
|
||||||
@@ -49,8 +48,6 @@ export default function NavSidebar({
|
|||||||
onToggleCollapse,
|
onToggleCollapse,
|
||||||
}: {
|
}: {
|
||||||
me: Me;
|
me: Me;
|
||||||
page: Page;
|
|
||||||
setPage: (p: Page) => void;
|
|
||||||
onOpenAbout: () => void;
|
onOpenAbout: () => void;
|
||||||
onChangeLanguage: (code: LangCode) => void;
|
onChangeLanguage: (code: LangCode) => void;
|
||||||
language: LangCode;
|
language: LangCode;
|
||||||
@@ -60,6 +57,8 @@ export default function NavSidebar({
|
|||||||
onToggleCollapse: () => void;
|
onToggleCollapse: () => void;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { page } = useNavigation();
|
||||||
|
const { setPage } = useNavigationActions();
|
||||||
// When unpinned, the rail sits slim (icons only) and peeks open into a labelled overlay on hover
|
// When unpinned, the rail sits slim (icons only) and peeks open into a labelled overlay on hover
|
||||||
// or keyboard focus WITHOUT pushing content. Pinned keeps it expanded in-flow like before.
|
// or keyboard focus WITHOUT pushing content. Pinned keeps it expanded in-flow like before.
|
||||||
// `collapsed` (persisted per-account) now means "unpinned".
|
// `collapsed` (persisted per-account) now means "unpinned".
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import {
|
|||||||
type VideoWatchedMeta,
|
type VideoWatchedMeta,
|
||||||
} from "../lib/notifications";
|
} from "../lib/notifications";
|
||||||
import { channelYouTubeUrl, relativeFromMs, relativeTime } from "../lib/format";
|
import { channelYouTubeUrl, relativeFromMs, relativeTime } from "../lib/format";
|
||||||
import type { Page } from "../lib/urlState";
|
|
||||||
import { LEVEL_STYLE } from "./Toaster";
|
import { LEVEL_STYLE } from "./Toaster";
|
||||||
|
import { useNavigationActions } from "./NavigationProvider";
|
||||||
|
|
||||||
// The single notification center. "System" = durable, server-backed notifications (inbox
|
// The single notification center. "System" = durable, server-backed notifications (inbox
|
||||||
// phase 1). "Activity" = the client-side transient events (action confirmations, errors, with
|
// phase 1). "Activity" = the client-side transient events (action confirmations, errors, with
|
||||||
@@ -32,15 +32,14 @@ const POLL_MS = 8000;
|
|||||||
export default function NotificationsPanel({
|
export default function NotificationsPanel({
|
||||||
filters,
|
filters,
|
||||||
setFilters,
|
setFilters,
|
||||||
setPage,
|
|
||||||
onFocusChannel,
|
onFocusChannel,
|
||||||
}: {
|
}: {
|
||||||
filters: FeedFilters;
|
filters: FeedFilters;
|
||||||
setFilters: (f: FeedFilters) => void;
|
setFilters: (f: FeedFilters) => void;
|
||||||
setPage: (p: Page) => void;
|
|
||||||
onFocusChannel: (name: string) => void;
|
onFocusChannel: (name: string) => void;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { setPage } = useNavigationActions();
|
||||||
const qc = useQueryClient();
|
const qc = useQueryClient();
|
||||||
const q = useLiveQuery<{ items: AppNotification[]; total: number }>(
|
const q = useLiveQuery<{ items: AppNotification[]; total: number }>(
|
||||||
["notifications"],
|
["notifications"],
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { createPortal } from "react-dom";
|
import { createPortal } from "react-dom";
|
||||||
|
import { useNavigationActions } from "./NavigationProvider";
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { AlertTriangle, ArrowLeft, Check, CheckCheck, ChevronLeft, ChevronRight, ExternalLink, Repeat, Repeat1, Settings, Shuffle, SkipBack, SkipForward, Volume2, VolumeX, X } from "lucide-react";
|
import { AlertTriangle, ArrowLeft, Check, CheckCheck, ChevronLeft, ChevronRight, ExternalLink, Repeat, Repeat1, Settings, Shuffle, SkipBack, SkipForward, Volume2, VolumeX, X } from "lucide-react";
|
||||||
import Avatar from "./Avatar";
|
import Avatar from "./Avatar";
|
||||||
@@ -55,7 +56,6 @@ export default function PlayerModal({
|
|||||||
startIndex,
|
startIndex,
|
||||||
onClose,
|
onClose,
|
||||||
onState,
|
onState,
|
||||||
onOpenChannel,
|
|
||||||
}: {
|
}: {
|
||||||
video: Video;
|
video: Video;
|
||||||
// Where to start the opened video: a number of seconds (0 = Restart), or null/undefined
|
// Where to start the opened video: a number of seconds (0 = Restart), or null/undefined
|
||||||
@@ -70,9 +70,9 @@ export default function PlayerModal({
|
|||||||
onState: (id: string, status: string) => void;
|
onState: (id: string, status: string) => void;
|
||||||
// Open the active video's channel page in-app (closes the player first). The small external
|
// Open the active video's channel page in-app (closes the player first). The small external
|
||||||
// icon next to the name keeps the open-on-YouTube behaviour.
|
// icon next to the name keeps the open-on-YouTube behaviour.
|
||||||
onOpenChannel?: (channelId: string, channelName?: string) => void;
|
|
||||||
}) {
|
}) {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
const { openChannel } = useNavigationActions();
|
||||||
const qc = useQueryClient();
|
const qc = useQueryClient();
|
||||||
const descFade = useScrollFade();
|
const descFade = useScrollFade();
|
||||||
// Browser/mouse Back closes the player instead of leaving the page.
|
// Browser/mouse Back closes the player instead of leaving the page.
|
||||||
@@ -840,16 +840,15 @@ export default function PlayerModal({
|
|||||||
<div className="flex items-center gap-1.5 shrink-0 min-w-0">
|
<div className="flex items-center gap-1.5 shrink-0 min-w-0">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!onOpenChannel) return onClose();
|
|
||||||
const cid = active.channel_id;
|
const cid = active.channel_id;
|
||||||
const cname = active.channel_title ?? undefined;
|
const cname = active.channel_title ?? undefined;
|
||||||
// Closing the player pops its own history entry (useBackToClose → history.back()).
|
// Closing the player pops its own history entry (useBackToClose → history.back()).
|
||||||
// Open the channel only AFTER that pop's popstate — pushing the channel entry
|
// Open the channel only AFTER that pop's popstate — pushing the channel entry
|
||||||
// before it would let the back remove it again (the bug: clicking the name only
|
// before it would let the back remove it again (the bug: clicking the name only
|
||||||
// closed the player). One-shot listener fires after App's popstate handler.
|
// closed the player). One-shot listener fires after the popstate handler.
|
||||||
const open = () => {
|
const open = () => {
|
||||||
window.removeEventListener("popstate", open);
|
window.removeEventListener("popstate", open);
|
||||||
onOpenChannel(cid, cname);
|
openChannel(cid, cname);
|
||||||
};
|
};
|
||||||
window.addEventListener("popstate", open);
|
window.addEventListener("popstate", open);
|
||||||
onClose();
|
onClose();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { memo, useEffect, useRef, useState } from "react";
|
import { memo, useEffect, useRef, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useNavigationActions } from "./NavigationProvider";
|
||||||
import {
|
import {
|
||||||
Bookmark,
|
Bookmark,
|
||||||
Check,
|
Check,
|
||||||
@@ -368,7 +369,6 @@ function VideoCard({
|
|||||||
onState,
|
onState,
|
||||||
onResetState,
|
onResetState,
|
||||||
onToggleSave,
|
onToggleSave,
|
||||||
onOpenChannel,
|
|
||||||
onOpen,
|
onOpen,
|
||||||
}: {
|
}: {
|
||||||
video: Video;
|
video: Video;
|
||||||
@@ -378,10 +378,10 @@ function VideoCard({
|
|||||||
onState: (id: string, status: string) => void;
|
onState: (id: string, status: string) => void;
|
||||||
onResetState?: (id: string) => void;
|
onResetState?: (id: string) => void;
|
||||||
onToggleSave: (id: string, saved: boolean) => void;
|
onToggleSave: (id: string, saved: boolean) => void;
|
||||||
onOpenChannel?: (channelId: string, channelName: string) => void;
|
|
||||||
onOpen?: (v: Video, startAt?: number | null) => void;
|
onOpen?: (v: Video, startAt?: number | null) => void;
|
||||||
}) {
|
}) {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
const { openChannel } = useNavigationActions();
|
||||||
const spec = FEED_VIEW_SPEC[view];
|
const spec = FEED_VIEW_SPEC[view];
|
||||||
const watched = video.status === "watched";
|
const watched = video.status === "watched";
|
||||||
// The thumbnail-less row drops Thumb, and with it the duration / live state / saved marker that
|
// The thumbnail-less row drops Thumb, and with it the duration / live state / saved marker that
|
||||||
@@ -451,7 +451,7 @@ function VideoCard({
|
|||||||
data-testid="video-card-channel"
|
data-testid="video-card-channel"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onOpenChannel?.(video.channel_id, video.channel_title ?? t("card.thisChannel"));
|
openChannel(video.channel_id, video.channel_title ?? t("card.thisChannel"));
|
||||||
}}
|
}}
|
||||||
title={channelClamped ? video.channel_title ?? undefined : undefined}
|
title={channelClamped ? video.channel_title ?? undefined : undefined}
|
||||||
className="text-sm text-muted truncate block w-fit max-w-full text-left hover:text-fg"
|
className="text-sm text-muted truncate block w-fit max-w-full text-left hover:text-fg"
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ export interface VirtualFeedProps {
|
|||||||
view: FeedView;
|
view: FeedView;
|
||||||
onState: (id: string, status: string) => void;
|
onState: (id: string, status: string) => void;
|
||||||
onToggleSave: (id: string, saved: boolean) => void;
|
onToggleSave: (id: string, saved: boolean) => void;
|
||||||
onOpenChannel: (channelId: string, channelName: string) => void;
|
|
||||||
onResetState: (id: string) => void;
|
onResetState: (id: string) => void;
|
||||||
onOpen: (v: Video, startAt?: number | null) => void;
|
onOpen: (v: Video, startAt?: number | null) => void;
|
||||||
hasNextPage: boolean;
|
hasNextPage: boolean;
|
||||||
@@ -71,7 +70,6 @@ export default function VirtualFeed({
|
|||||||
view,
|
view,
|
||||||
onState,
|
onState,
|
||||||
onToggleSave,
|
onToggleSave,
|
||||||
onOpenChannel,
|
|
||||||
onResetState,
|
onResetState,
|
||||||
onOpen,
|
onOpen,
|
||||||
hasNextPage,
|
hasNextPage,
|
||||||
@@ -187,7 +185,6 @@ export default function VirtualFeed({
|
|||||||
width={FEED_VIEW_SPEC[view].thumb ? 0 : itemWidth}
|
width={FEED_VIEW_SPEC[view].thumb ? 0 : itemWidth}
|
||||||
onState={onState}
|
onState={onState}
|
||||||
onToggleSave={onToggleSave}
|
onToggleSave={onToggleSave}
|
||||||
onOpenChannel={onOpenChannel}
|
|
||||||
onResetState={onResetState}
|
onResetState={onResetState}
|
||||||
onOpen={onOpen}
|
onOpen={onOpen}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user