Skip to content

Commit

Permalink
make livetab work on v3
Browse files Browse the repository at this point in the history
  • Loading branch information
sphinxrave committed Dec 27, 2024
1 parent 7b6e596 commit 1a1df27
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions packages/react/src/components/edit/VideoEditTopic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function VideoEditTopic({ video }: { video: Video }) {
key={channel.id}
{...channel}
size="xs"
variant="list"
showSubscribers={false}
>
<Button
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/layout/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import React from "react";
import { useOrgs } from "@/services/orgs.service";
import { useTimeout } from "usehooks-ts";
import { defaultOpenAtom } from "@/store/settings";
//@ts-expect-error commitssincelasttag
import {
abbreviatedSha,
committerDate,
lastTag,
//@ts-expect-error commitssincelasttag
commitsSinceLastTag,
} from "~build/git";
import dayjs from "dayjs";
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/routes/favorites/favoritedChannels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function FavoritedChannels() {
data={favChannels?.flat() ?? []}
itemContent={(_, channel) => (
<MemoizedChannelCard
variant="card"
key={"fav_card_" + channel.id}
size="lg"
{...channel}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/routes/home/LiveTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function LiveTab() {
);

const liveFiltered = useVideoFilter(
live as Video[],
live?.items as Video[],
"stream_schedule",
"org",
);
Expand Down
6 changes: 4 additions & 2 deletions packages/react/src/routes/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ function StickyTabsList({
{t("views.home.recentVideoToggles.subber")}
</TabsTrigger>
<TabsTrigger value="members">{fourthTab}</TabsTrigger>
<Separator orientation="vertical" className="relative h-auto" />
<Separator orientation="vertical" className="relative h-10" />
{/* The h-10 on this separator is actually load bearing - it maintains the height of the whole tab list */}
{/* Optional Control Buttons */}
{tab === "clips" && <ClipLanguageSelector />}
<CardSizeToggle />
{tab !== "members" && <CardSizeToggle />}
</TabsList>
);
}
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/routes/settings/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ export function SettingsContentPreferences() {
{blockedChannels.length ? (
<div className="grid w-full grid-cols-[repeat(auto-fill,_minmax(240px,_1fr))]">
{blockedChannels.map((channel) => (
<ChannelCard key={channel.id} size="lg" {...channel} />
<ChannelCard
variant="card"
key={channel.id}
size="lg"
{...channel}
/>
))}
</div>
) : (
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/routes/watch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function Watch() {
"px-4 @screen-lg:px-8 pb-8": theaterMode,
})}
>
{channel && <ChannelCard size="xs" {...channel} />}
{channel && <ChannelCard size="xs" variant="list" {...channel} />}
{!currentVideo?.link?.includes("twitch") &&
currentVideo?.description && (
<PlayerDescription description={currentVideo.description} />
Expand Down
6 changes: 4 additions & 2 deletions packages/react/src/services/live.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useClient } from "@/hooks/useClient";
import { hidePlaceholderAtom } from "@/store/settings";
import { useQuery } from "@tanstack/react-query";
import { useAtomValue } from "jotai";
import { VideoServiceResponse } from "./video.service";

interface UseLiveParams {
channel_id?: string;
Expand Down Expand Up @@ -31,12 +32,13 @@ const STANDARD_CONFIG_LIVE_QUERY = {
export function useLive(params?: UseLiveParams, config?: CommonQueryConfig) {
const client = useClient();

return useQuery<Live[]>({
return useQuery({
queryKey: ["live", params],
queryFn: async () =>
await client<Live[]>("/api/v2/live", {
await client<VideoServiceResponse<Live>>("/api/v3/live", {
params: {
...params,
limit: 3000,
},
}),
...STANDARD_CONFIG_LIVE_QUERY,
Expand Down
16 changes: 0 additions & 16 deletions packages/react/src/services/services.scratch.http

This file was deleted.

6 changes: 6 additions & 0 deletions packages/react/src/services/video.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ function arrayToCommaSeparatedString(arr: string[] | string | undefined) {
return Array.isArray(arr) ? arr.join(",") : arr;
}

export type VideoServiceResponse<VideoType> = {
items: VideoType[];
approximateTotal: number;
nextPage?: string;
};

export function useVideosV3(
params?: Omit<UseVideosV3Params, "nextPage">,
config?: CommonQueryConfig,
Expand Down

0 comments on commit 1a1df27

Please sign in to comment.