diff --git a/package.json b/package.json index e7f9ad0..82a5d39 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@webscopeio/react-textarea-autocomplete": "^4.9.2", "hls.js": "^1.4.6", "lodash": "^4.17.21", + "moment": "^2.29.4", "qr-code-styling": "^1.6.0-rc.1", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/src/element/new-stream.tsx b/src/element/new-stream.tsx index 7a15400..fa397a5 100644 --- a/src/element/new-stream.tsx +++ b/src/element/new-stream.tsx @@ -5,15 +5,9 @@ import { EventPublisher, NostrEvent } from "@snort/system"; import { unixNow } from "@snort/shared"; import AsyncButton from "./async-button"; -import { System } from "index"; +import { StreamState, System } from "index"; import { findTag } from "utils"; -enum StreamState { - Live = "live", - Ended = "ended", - Planned = "planned" -} - export function NewStream({ ev, onFinish, @@ -26,6 +20,7 @@ export function NewStream({ const [image, setImage] = useState(findTag(ev, "image") ?? ""); const [stream, setStream] = useState(findTag(ev, "streaming") ?? ""); const [status, setStatus] = useState(findTag(ev, "status") ?? StreamState.Live); + const [start, setStart] = useState(findTag(ev, "starts")); const [isValid, setIsValid] = useState(false); function validate() { @@ -51,7 +46,7 @@ export function NewStream({ const evNew = await pub.generic((eb) => { const now = unixNow(); const dTag = findTag(ev, "d") ?? now.toString(); - const starts = findTag(ev, "starts") ?? now.toString(); + const starts = start ?? now.toString(); const ends = findTag(ev, "ends") ?? now.toString(); eb .kind(30_311) @@ -73,6 +68,16 @@ export function NewStream({ } } + function toDateTimeString(n: number) { + console.debug(n); + return new Date(n * 1000).toISOString().substring(0, -1) + } + + function fromDateTimeString(s: string) { + console.debug(s); + return Math.floor(new Date(s).getTime() / 1000) + } + return (
Start Time
+{findTag(thisEvent.data, "summary")}