Skip to content

Commit

Permalink
missing video spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sphinxrave committed Dec 30, 2024
1 parent fe647e4 commit b365161
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 22 additions & 2 deletions packages/react/src/components/video/VideoCardCountdownToLive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import React from "react";
import { cn } from "@/lib/utils";
import { useInterval } from "usehooks-ts";

const incr = 0;

interface LiveCounterProps {
viewers?: number;
start_date?: string;
Expand Down Expand Up @@ -150,6 +148,28 @@ export function VideoCardCountdownToLive({
);
}

// Handle missing videos
if (video.status === "missing") {
if (video.start_actual) {
const tick = dayjs(video.start_actual);
return (
<TimeTooltip id={video.id} timestamp={tick} className={className}>
<div className="i-ph:image-broken inline-block align-text-bottom opacity-80" />
&nbsp;Streamed at {tick.format("LLL")}
</TimeTooltip>
);
}
if (video.start_scheduled) {
const tick = dayjs(video.start_scheduled);
return (
<TimeTooltip id={video.id} timestamp={Date.now()} className={className}>
<div className="i-ph:image-broken inline-block align-text-bottom opacity-80" />
&nbsp;Scheduled for {tick.format("LLL")}
</TimeTooltip>
);
}
}

return null;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/hooks/useDuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export function useDuration({
>) {
const [date] = useSeconds();

if (status === "missing") return duration ? duration * 1000 : null;

if (status === "past") return duration * 1000;

if (status === "live" && start_actual)
Expand Down

0 comments on commit b365161

Please sign in to comment.