fix: planned stream dashboard
This commit is contained in:
@ -145,13 +145,7 @@ export function StreamEditor({ ev, onFinish, options }: StreamEditorProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toDateTimeString(n: number) {
|
const startsDate = new Date(parseInt(start ?? "0") * 1000);
|
||||||
return new Date(n * 1000).toISOString().substring(0, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fromDateTimeString(s: string) {
|
|
||||||
return Math.floor(new Date(s).getTime() / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -209,8 +203,10 @@ export function StreamEditor({ ev, onFinish, options }: StreamEditorProps) {
|
|||||||
<StreamInput label={<FormattedMessage defaultMessage="Start Time" />}>
|
<StreamInput label={<FormattedMessage defaultMessage="Start Time" />}>
|
||||||
<input
|
<input
|
||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
value={toDateTimeString(Number(start ?? "0"))}
|
value={`${startsDate.getFullYear().toString().padStart(4, "0")}-${startsDate.getMonth().toString().padStart(2, "0")}-${startsDate.getDate().toString().padStart(2, "0")}T${startsDate.getHours().toString().padStart(2, "0")}:${startsDate.getMinutes().toString().padStart(2, "0")}`}
|
||||||
onChange={e => setStart(fromDateTimeString(e.target.value).toString())}
|
onChange={e => {
|
||||||
|
setStart((e.target.valueAsNumber / 1000).toString());
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</StreamInput>
|
</StreamInput>
|
||||||
)}
|
)}
|
||||||
|
@ -49,7 +49,7 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
|
|||||||
|
|
||||||
const provider = useMemo(() => (service ? new NostrStreamProvider("", service) : DefaultProvider), [service]);
|
const provider = useMemo(() => (service ? new NostrStreamProvider("", service) : DefaultProvider), [service]);
|
||||||
const defaultEndpoint = useMemo(() => {
|
const defaultEndpoint = useMemo(() => {
|
||||||
return info?.endpoints.find(a => a.name == (recording ? "Best" : "Good")) ?? info?.endpoints[0];
|
return info?.endpoints?.find(a => a.name == (recording ? "Best" : "Good")) ?? info?.endpoints?.at(0);
|
||||||
}, [info, recording]);
|
}, [info, recording]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -84,28 +84,44 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
|
|||||||
|
|
||||||
if (!streamLink && !location.search.includes("setupComplete=true")) return <DashboardIntro />;
|
if (!streamLink && !location.search.includes("setupComplete=true")) return <DashboardIntro />;
|
||||||
|
|
||||||
|
function headingText() {
|
||||||
|
switch (status) {
|
||||||
|
case StreamState.Live:
|
||||||
|
return <FormattedMessage defaultMessage="Started" />;
|
||||||
|
case StreamState.Ended:
|
||||||
|
return <FormattedMessage defaultMessage="Stopped" />;
|
||||||
|
case StreamState.Planned:
|
||||||
|
return <FormattedMessage defaultMessage="Planned" />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function headingDotStyle() {
|
||||||
|
switch (status) {
|
||||||
|
case StreamState.Live:
|
||||||
|
return "animate-pulse bg-green-500";
|
||||||
|
case StreamState.Ended:
|
||||||
|
return "bg-red-500";
|
||||||
|
case StreamState.Planned:
|
||||||
|
return "bg-yellow-500";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames("grid gap-2 h-[calc(100dvh-52px)] w-full", {
|
className={classNames("grid gap-2 h-[calc(100dvh-52px)] w-full", {
|
||||||
"grid-cols-3": status === StreamState.Live,
|
"grid-cols-3": status === StreamState.Live,
|
||||||
"grid-cols-[20%_80%]": status === StreamState.Ended,
|
"grid-cols-[20%_80%]": status === StreamState.Ended,
|
||||||
|
"grid-cols-[40%_60%]": status === StreamState.Planned,
|
||||||
})}>
|
})}>
|
||||||
<div className="min-h-0 h-full grid grid-rows-[min-content_auto] gap-2">
|
<div className="min-h-0 h-full grid grid-rows-[min-content_auto] gap-2">
|
||||||
<DashboardCard className="flex flex-col gap-4">
|
<DashboardCard className="flex flex-col gap-4">
|
||||||
<div className="flex justify-between items-center">
|
<div className="flex justify-between items-center">
|
||||||
<h3>
|
<h3>
|
||||||
<FormattedMessage defaultMessage="Stream" id="uYw2LD" />
|
<FormattedMessage defaultMessage="Stream" />
|
||||||
</h3>
|
</h3>
|
||||||
<div className="uppercase font-semibold flex items-center gap-2">
|
<div className="uppercase font-semibold flex items-center gap-2">
|
||||||
<div
|
<div className={`w-3 h-3 rounded-full ${headingDotStyle()}`}></div>
|
||||||
className={`w-3 h-3 rounded-full ${
|
{headingText()}
|
||||||
status === StreamState.Live ? "animate-pulse bg-green-500" : "bg-red-500"
|
|
||||||
}`}></div>
|
|
||||||
{status === StreamState.Live ? (
|
|
||||||
<FormattedMessage defaultMessage="Started" />
|
|
||||||
) : (
|
|
||||||
<FormattedMessage defaultMessage="Stopped" />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{streamLink && status === StreamState.Live && !isMyManual && (
|
{streamLink && status === StreamState.Live && !isMyManual && (
|
||||||
@ -152,7 +168,7 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{streamLink && isMyManual && status === StreamState.Live && (
|
{streamLink && isMyManual && (status === StreamState.Live || status === StreamState.Planned) && (
|
||||||
<>
|
<>
|
||||||
<LiveVideoPlayer stream={stream} status={status} poster={image} muted={true} className="w-full" />
|
<LiveVideoPlayer stream={stream} status={status} poster={image} muted={true} className="w-full" />
|
||||||
<div className="grid gap-2 grid-cols-3">
|
<div className="grid gap-2 grid-cols-3">
|
||||||
@ -223,7 +239,7 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
|
|||||||
</div>
|
</div>
|
||||||
</DashboardCard>
|
</DashboardCard>
|
||||||
)}
|
)}
|
||||||
{(!streamLink || status === StreamState.Ended) && (
|
{(!streamLink || status !== StreamState.Live) && (
|
||||||
<DashboardCard className="flex flex-col gap-4">
|
<DashboardCard className="flex flex-col gap-4">
|
||||||
<h3>
|
<h3>
|
||||||
<FormattedMessage defaultMessage="Account Setup" />
|
<FormattedMessage defaultMessage="Account Setup" />
|
||||||
@ -266,6 +282,7 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
|
|||||||
</DashboardCard>
|
</DashboardCard>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{streamLink && status === StreamState.Planned && <DashboardCard className="overflow-y-auto"></DashboardCard>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { base64 } from "@scure/base";
|
import { base64 } from "@scure/base";
|
||||||
import { StreamProvider, StreamProviderEndpoint, StreamProviderInfo, StreamProviders } from ".";
|
import { StreamProvider, StreamProviderEndpoint, StreamProviders } from ".";
|
||||||
import { EventKind, EventPublisher, NostrEvent, SystemInterface } from "@snort/system";
|
import { EventKind, EventPublisher, NostrEvent, SystemInterface } from "@snort/system";
|
||||||
import { Login } from "@/login";
|
import { Login } from "@/login";
|
||||||
import { getPublisher } from "@/login";
|
import { getPublisher } from "@/login";
|
||||||
import { extractStreamInfo } from "@/utils";
|
import { extractStreamInfo } from "@/utils";
|
||||||
import { StreamState } from "@/const";
|
|
||||||
import { appendDedupe, unixNow } from "@snort/shared";
|
import { appendDedupe, unixNow } from "@snort/shared";
|
||||||
import { TimeSync } from "@/time-sync";
|
import { TimeSync } from "@/time-sync";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user