feat: update stream status

This commit is contained in:
2023-06-25 21:20:23 +01:00
parent d7a17ae094
commit 93d0ead54e
4 changed files with 34 additions and 2 deletions

View File

@ -37,3 +37,16 @@
.new-stream .btn:disabled { .new-stream .btn:disabled {
opacity: 0.3; opacity: 0.3;
} }
.new-stream .pill {
border-radius: 16px;
background: #262626;
padding: 8px 12px;
text-align: center;
text-transform: uppercase;
}
.new-stream .pill.active {
color: inherit;
background: #353535;
}

View File

@ -1,11 +1,19 @@
import "./new-stream.css";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { EventPublisher, NostrEvent } from "@snort/system"; import { EventPublisher, NostrEvent } from "@snort/system";
import { unixNow } from "@snort/shared"; import { unixNow } from "@snort/shared";
import "./new-stream.css";
import AsyncButton from "./async-button"; import AsyncButton from "./async-button";
import { System } from "index"; import { System } from "index";
import { findTag } from "utils"; import { findTag } from "utils";
enum StreamState {
Live = "live",
Ended = "ended",
Planned = "planned"
}
export function NewStream({ export function NewStream({
ev, ev,
onFinish, onFinish,
@ -17,6 +25,7 @@ export function NewStream({
const [summary, setSummary] = useState(findTag(ev, "summary") ?? ""); const [summary, setSummary] = useState(findTag(ev, "summary") ?? "");
const [image, setImage] = useState(findTag(ev, "image") ?? ""); const [image, setImage] = useState(findTag(ev, "image") ?? "");
const [stream, setStream] = useState(findTag(ev, "streaming") ?? ""); const [stream, setStream] = useState(findTag(ev, "streaming") ?? "");
const [status, setStatus] = useState(findTag(ev, "status") ?? StreamState.Live);
const [isValid, setIsValid] = useState(false); const [isValid, setIsValid] = useState(false);
function validate() { function validate() {
@ -49,7 +58,7 @@ export function NewStream({
.tag(["summary", summary]) .tag(["summary", summary])
.tag(["image", image]) .tag(["image", image])
.tag(["streaming", stream]) .tag(["streaming", stream])
.tag(["status", "live"]); .tag(["status", status]);
}); });
console.debug(evNew); console.debug(evNew);
System.BroadcastEvent(evNew); System.BroadcastEvent(evNew);
@ -105,6 +114,14 @@ export function NewStream({
</div> </div>
<small>Stream type should be HLS</small> <small>Stream type should be HLS</small>
</div> </div>
<div>
<p>Status</p>
<div className="flex g12">
{[StreamState.Live, StreamState.Planned, StreamState.Ended].map(v => <span className={`pill${status === v ? " active" : ""}`} onClick={() => setStatus(v)}>
{v}
</span>)}
</div>
</div>
<div> <div>
<AsyncButton <AsyncButton
type="button" type="button"

View File

@ -18,4 +18,5 @@
.video-tile .pill { .video-tile .pill {
float: right; float: right;
margin: 16px 20px 0 0; margin: 16px 20px 0 0;
text-transform: uppercase;
} }

View File

@ -30,6 +30,7 @@
.live-page .pill.live { .live-page .pill.live {
color: inherit; color: inherit;
text-transform: uppercase;
} }
.live-page .info { .live-page .info {