Merge branch 'main' into emotes

This commit is contained in:
Alejandro Gomez
2023-06-24 14:50:57 +02:00
3 changed files with 130 additions and 87 deletions

View File

@ -1,6 +1,11 @@
import { Icon } from "element/icon";
import "./layout.css";
import { EventPublisher } from "@snort/system";
import {
EventPublisher,
NostrEvent,
encodeTLV,
NostrPrefix,
} from "@snort/system";
import { Outlet, useNavigate } from "react-router-dom";
import AsyncButton from "element/async-button";
import { Login } from "index";
@ -58,6 +63,19 @@ export function LayoutPage() {
);
}
function goToStream(ev: NostrEvent) {
const d = ev.tags.find((t) => t.at(0) === "d")?.at(1) || "";
const naddr = encodeTLV(
NostrPrefix.Address,
d,
undefined,
ev.kind,
ev.pubkey
);
navigate(`/live/${naddr}`);
setNewStream(false);
}
return (
<>
<header>
@ -74,7 +92,7 @@ export function LayoutPage() {
<Outlet />
{newStream && (
<Modal onClose={() => setNewStream(false)}>
<NewStream onFinish={() => navigate("/")} />
<NewStream onFinish={goToStream} />
</Modal>
)}
</>