- Backend: /history/years and /history/:year return every movie and episode watch in a year, with entry posters, genres, networks and buddies - History tab: watches by month and day, back-to-back episodes grouped - Timeline tab: latest to oldest, month dividers, stacked binge sessions - Year in Review tab: hours, top shows and genres, streaks, busiest day, biggest binge, monthly and weekday charts, buddies and new shows - Year picker, movies/TV filter, state kept in the URL; unknown-date watches badged and excluded from the review by default - History link in the sidebar and command palette
322 lines
8.1 KiB
TypeScript
322 lines
8.1 KiB
TypeScript
import { createBrowserRouter, createHashRouter } from "react-router-dom";
|
|
import { lazy, Suspense, type ReactNode } from "react";
|
|
import { AppLayout } from "@/components/layout/AppLayout";
|
|
import {
|
|
DashboardSkeleton,
|
|
HomeSkeleton,
|
|
LibrarySkeleton,
|
|
WatchlistSkeleton,
|
|
CollectionsSkeleton,
|
|
CollectionDetailsSkeleton,
|
|
EntryDetailsSkeleton,
|
|
SeasonSkeleton,
|
|
EpisodeSkeleton,
|
|
PeopleSkeleton,
|
|
PersonDetailsSkeleton,
|
|
MediaSkeleton,
|
|
CalendarSkeleton,
|
|
SettingsSkeleton,
|
|
DiscoveryVideosSkeleton,
|
|
} from "@/components/skeletons/PageSkeletons";
|
|
|
|
// Lazy-loaded pages
|
|
const HomePage = lazy(() =>
|
|
import("@/pages/HomePage").then((m) => ({ default: m.HomePage })),
|
|
);
|
|
const DashboardPage = lazy(() =>
|
|
import("@/pages/DashboardPage").then((m) => ({ default: m.DashboardPage })),
|
|
);
|
|
const HistoryPage = lazy(() =>
|
|
import("@/pages/HistoryPage").then((m) => ({ default: m.HistoryPage })),
|
|
);
|
|
const LibraryPage = lazy(() =>
|
|
import("@/pages/LibraryPage").then((m) => ({ default: m.LibraryPage })),
|
|
);
|
|
const WatchlistPage = lazy(() =>
|
|
import("@/pages/WatchlistPage").then((m) => ({ default: m.WatchlistPage })),
|
|
);
|
|
const CollectionsPage = lazy(() =>
|
|
import("@/pages/CollectionsPage").then((m) => ({
|
|
default: m.CollectionsPage,
|
|
})),
|
|
);
|
|
const CollectionDetailsPage = lazy(() =>
|
|
import("@/pages/CollectionDetailsPage").then((m) => ({
|
|
default: m.CollectionDetailsPage,
|
|
})),
|
|
);
|
|
const MediaPage = lazy(() =>
|
|
import("@/pages/MediaPage").then((m) => ({ default: m.MediaPage })),
|
|
);
|
|
const CalendarPage = lazy(() =>
|
|
import("@/pages/CalendarPage").then((m) => ({ default: m.CalendarPage })),
|
|
);
|
|
const EntryDetailsPage = lazy(() =>
|
|
import("@/pages/EntryDetailsPage").then((m) => ({
|
|
default: m.EntryDetailsPage,
|
|
})),
|
|
);
|
|
const TmdbCastsPage = lazy(() =>
|
|
import("@/pages/TmdbCastsPage").then((m) => ({
|
|
default: m.TmdbCastsPage,
|
|
})),
|
|
);
|
|
const SeasonPage = lazy(() =>
|
|
import("@/pages/SeasonPage").then((m) => ({ default: m.SeasonPage })),
|
|
);
|
|
const EpisodePage = lazy(() =>
|
|
import("@/pages/EpisodePage").then((m) => ({ default: m.EpisodePage })),
|
|
);
|
|
const EntryCastsPage = lazy(() =>
|
|
import("@/pages/EntryCastsPage").then((m) => ({
|
|
default: m.EntryCastsPage,
|
|
})),
|
|
);
|
|
const PeoplePage = lazy(() =>
|
|
import("@/pages/PeoplePage").then((m) => ({ default: m.PeoplePage })),
|
|
);
|
|
const WatchBuddiesPage = lazy(() =>
|
|
import("@/pages/WatchBuddiesPage").then((m) => ({
|
|
default: m.WatchBuddiesPage,
|
|
})),
|
|
);
|
|
const WatchBuddyProfilePage = lazy(() =>
|
|
import("@/pages/WatchBuddyProfilePage").then((m) => ({
|
|
default: m.WatchBuddyProfilePage,
|
|
})),
|
|
);
|
|
const PersonDetailsPage = lazy(() =>
|
|
import("@/pages/PersonDetailsPage").then((m) => ({
|
|
default: m.PersonDetailsPage,
|
|
})),
|
|
);
|
|
const SettingsPage = lazy(() =>
|
|
import("@/pages/SettingsPage").then((m) => ({ default: m.SettingsPage })),
|
|
);
|
|
const DiscoveryVideosPage = lazy(() =>
|
|
import("@/pages/DiscoveryVideosPage").then((m) => ({
|
|
default: m.DiscoveryVideosPage,
|
|
})),
|
|
);
|
|
const DiscoverPage = lazy(() =>
|
|
import("@/pages/DiscoverPage").then((m) => ({ default: m.DiscoverPage })),
|
|
);
|
|
const SearchPage = lazy(() =>
|
|
import("@/pages/SearchPage").then((m) => ({ default: m.SearchPage })),
|
|
);
|
|
|
|
function SuspensePage({
|
|
children,
|
|
fallback,
|
|
}: {
|
|
children: ReactNode;
|
|
fallback?: ReactNode;
|
|
}) {
|
|
return (
|
|
<Suspense fallback={fallback ?? <HomeSkeleton />}>{children}</Suspense>
|
|
);
|
|
}
|
|
|
|
const isElectron = import.meta.env.VITE_ELECTRON === "true";
|
|
const createRouter = isElectron ? createHashRouter : createBrowserRouter;
|
|
|
|
export const router = createRouter([
|
|
{
|
|
element: <AppLayout />,
|
|
children: [
|
|
{
|
|
path: "/",
|
|
element: (
|
|
<SuspensePage fallback={<HomeSkeleton />}>
|
|
<HomePage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/search",
|
|
element: (
|
|
<SuspensePage fallback={<HomeSkeleton />}>
|
|
<SearchPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/dashboard",
|
|
element: (
|
|
<SuspensePage fallback={<DashboardSkeleton />}>
|
|
<DashboardPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/library",
|
|
element: (
|
|
<SuspensePage fallback={<LibrarySkeleton />}>
|
|
<LibraryPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/discover/:category",
|
|
element: (
|
|
<SuspensePage fallback={<HomeSkeleton />}>
|
|
<DiscoverPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/history",
|
|
element: (
|
|
<SuspensePage fallback={<WatchlistSkeleton />}>
|
|
<HistoryPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/watchlist",
|
|
element: (
|
|
<SuspensePage fallback={<WatchlistSkeleton />}>
|
|
<WatchlistPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/collections",
|
|
element: (
|
|
<SuspensePage fallback={<CollectionsSkeleton />}>
|
|
<CollectionsPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/collections/:id",
|
|
element: (
|
|
<SuspensePage fallback={<CollectionDetailsSkeleton />}>
|
|
<CollectionDetailsPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/media",
|
|
element: (
|
|
<SuspensePage fallback={<MediaSkeleton />}>
|
|
<MediaPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/discovery-videos",
|
|
element: (
|
|
<SuspensePage fallback={<DiscoveryVideosSkeleton />}>
|
|
<DiscoveryVideosPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/calendar",
|
|
element: (
|
|
<SuspensePage fallback={<CalendarSkeleton />}>
|
|
<CalendarPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/entry/tmdb/:type/:tmdbId/cast",
|
|
element: (
|
|
<SuspensePage fallback={<PeopleSkeleton />}>
|
|
<TmdbCastsPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/entry/tmdb/:type/:tmdbId",
|
|
element: (
|
|
<SuspensePage fallback={<EntryDetailsSkeleton />}>
|
|
<EntryDetailsPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/entry/:id",
|
|
element: (
|
|
<SuspensePage fallback={<EntryDetailsSkeleton />}>
|
|
<EntryDetailsPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/entry/:id/cast",
|
|
element: (
|
|
<SuspensePage fallback={<PeopleSkeleton />}>
|
|
<EntryCastsPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/entry/:entryId/season/:seasonId",
|
|
element: (
|
|
<SuspensePage fallback={<SeasonSkeleton />}>
|
|
<SeasonPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/entry/:entryId/season/:seasonId/episode/:episodeId",
|
|
element: (
|
|
<SuspensePage fallback={<EpisodeSkeleton />}>
|
|
<EpisodePage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/people",
|
|
element: (
|
|
<SuspensePage fallback={<PeopleSkeleton />}>
|
|
<PeoplePage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/people/tmdb/:tmdbId",
|
|
element: (
|
|
<SuspensePage fallback={<PersonDetailsSkeleton />}>
|
|
<PersonDetailsPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/people/:id",
|
|
element: (
|
|
<SuspensePage fallback={<PersonDetailsSkeleton />}>
|
|
<PersonDetailsPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/watch-buddies",
|
|
element: (
|
|
<SuspensePage fallback={<PeopleSkeleton />}>
|
|
<WatchBuddiesPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/watch-buddies/:id",
|
|
element: (
|
|
<SuspensePage fallback={<PersonDetailsSkeleton />}>
|
|
<WatchBuddyProfilePage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
{
|
|
path: "/settings",
|
|
element: (
|
|
<SuspensePage fallback={<SettingsSkeleton />}>
|
|
<SettingsPage />
|
|
</SuspensePage>
|
|
),
|
|
},
|
|
],
|
|
},
|
|
]);
|