Skip to content

Commit

Permalink
fix(favorite): fix wrong livestream tab filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane committed Oct 12, 2023
1 parent 7d29f97 commit a621b12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
} from "../providers/Player";
import { useTranslation } from "react-i18next";
import { CardImage } from "./CardImage";
import { useColorScheme } from "@mantine/hooks";

const useStyles = createStyles((theme) => ({
card: {
Expand Down Expand Up @@ -75,6 +74,9 @@ interface CardProps {
component?: "div" | "li";
}

export const isLiveStream = (video: Video) =>
video.type === "livestream" || video.liveNow || video.lengthSeconds === 0;

export const Card: React.FC<CardProps> = memo(
({ video, component = "div" }) => {
const { handlePlay, loading } = usePlayVideo();
Expand All @@ -85,8 +87,6 @@ export const Card: React.FC<CardProps> = memo(
(thumbnail) => thumbnail.quality === "maxresdefault"
) as VideoThumbnail;

const videoDuration = displayTimeBySeconds(video.lengthSeconds);

return (
<MCard
withBorder
Expand All @@ -108,12 +108,12 @@ export const Card: React.FC<CardProps> = memo(
gap="xs"
style={{ zIndex: 2, position: "relative" }}
>
{videoDuration !== "00:00" ? (
{video.lengthSeconds > 0 ? (
<Badge variant="filled" size="xs">
{videoDuration}
{displayTimeBySeconds(video.lengthSeconds)}
</Badge>
) : null}
{video.liveNow || videoDuration === "00:00" ? (
{isLiveStream(video) ? (
<Badge variant="filled" size="xs" color="red">
{t("live")}
</Badge>
Expand Down
9 changes: 5 additions & 4 deletions src/components/FavoritePlaylist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
IconUser,
IconVideo,
} from "@tabler/icons-react";
import { isLiveStream } from "./Card";

export const FavoritePlaylist = memo(() => {
const favorite = useFavorite();
Expand All @@ -26,11 +27,11 @@ export const FavoritePlaylist = memo(() => {
}

const videos = data.filter(
(video) => video.type === "video" || video.type === "scheduled"
);
const livestream = data.filter(
(video) => video.type === "livestream" || video.liveNow
(video) =>
(video.type === "video" || video.type === "scheduled") &&
video.lengthSeconds > 0
);
const livestream = data.filter((video) => isLiveStream(video));
const playlists = data.filter((video) => video.type === "playlist");
const channels = data.filter((video) => video.type === "channel");

Expand Down

0 comments on commit a621b12

Please sign in to comment.