feat: enable recording checkbox

This commit is contained in:
kieran 2024-05-27 14:50:59 +01:00
parent 6457fe14a0
commit e2c34cef01
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
5 changed files with 21 additions and 5 deletions

View File

@ -153,7 +153,7 @@ const router = createBrowserRouter([
element: <StreamSummaryPage />,
},
{
path: "/dashboard",
path: "/dashboard/:id?",
element: (
<Suspense>
<DashboardPage />

View File

@ -393,6 +393,9 @@
"My6HwN": {
"defaultMessage": "Ok, it's safe"
},
"NTpJIm": {
"defaultMessage": "Enable Recording"
},
"NnHu0L": {
"defaultMessage": "Please upload at least 1 video"
},

View File

@ -39,11 +39,16 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
const [info, setInfo] = useState<StreamProviderInfo>();
const isMyManual = streamEvent?.pubkey === login?.pubkey;
const system = useContext(SnortContext);
const [recording, setRecording] = useState(Boolean(localStorage.getItem("default-recording") ?? "true"));
useEffect(() => {
localStorage.setItem("default-recording", String(recording));
}, [recording]);
const provider = useMemo(() => (service ? new NostrStreamProvider("", service) : DefaultProvider), [service]);
const defaultEndpoint = useMemo(() => {
return info?.endpoints.find(a => a.name == "Good");
}, [info]);
return info?.endpoints.find(a => a.name == (recording ? "Best" : "Good"));
}, [info, recording]);
useEffect(() => {
if (!isMyManual) {
@ -195,6 +200,10 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
}}
/>
</p>
<div className="flex gap-4 items-center">
<input type="checkbox" checked={recording} onChange={e => setRecording(e.target.checked)} />
<FormattedMessage defaultMessage="Enable Recording" />
</div>
{defaultEndpoint && <StreamKey ep={defaultEndpoint} />}
<ManualStream />
</div>

View File

@ -1,10 +1,13 @@
import { useLogin } from "@/hooks/login";
import { NostrLink, NostrPrefix } from "@snort/system";
import { NostrLink, NostrPrefix, parseNostrLink } from "@snort/system";
import { DashboardForLink } from "./dashboard";
import { useParams } from "react-router-dom";
export default function DashboardPage() {
const login = useLogin();
const { id } = useParams();
if (!login) return;
const link = id ? parseNostrLink(id) : new NostrLink(NostrPrefix.PublicKey, login.pubkey);
return <DashboardForLink link={new NostrLink(NostrPrefix.PublicKey, login.pubkey)} />;
return <DashboardForLink link={link} />;
}

View File

@ -130,6 +130,7 @@
"LxSJOb": "Go to Dashboard",
"MTHO1W": "Start Raid",
"My6HwN": "Ok, it's safe",
"NTpJIm": "Enable Recording",
"NnHu0L": "Please upload at least 1 video",
"O2Cy6m": "Yes, I am over 18",
"O7AeYh": "Description..",