2022-12-18 14:51:47 +00:00
|
|
|
import "./Root.css";
|
|
|
|
import Timeline from "./Timeline";
|
|
|
|
import { useSelector } from "react-redux";
|
2022-12-28 16:29:42 +00:00
|
|
|
import { useContext, useState } from "react";
|
|
|
|
import Event from "../nostr/Event";
|
|
|
|
import { NostrContext } from "..";
|
2022-12-18 14:51:47 +00:00
|
|
|
|
|
|
|
export default function RootPage() {
|
2022-12-28 16:29:42 +00:00
|
|
|
const system = useContext(NostrContext);
|
|
|
|
const pubKey = useSelector(s => s.login.publicKey);
|
|
|
|
const privKey = useSelector(s => s.login.privateKey);
|
|
|
|
const [note, setNote] = useState("");
|
|
|
|
|
|
|
|
async function sendNote() {
|
|
|
|
let ev = Event.NewNote(pubKey, note);
|
|
|
|
await ev.Sign(privKey);
|
|
|
|
|
|
|
|
console.debug("Sending note: ", ev);
|
|
|
|
system.BroadcastEvent(ev);
|
|
|
|
setNote("");
|
|
|
|
}
|
2022-12-18 14:51:47 +00:00
|
|
|
|
|
|
|
function noteSigner() {
|
|
|
|
return (
|
|
|
|
<div className="send-note">
|
2022-12-28 16:29:42 +00:00
|
|
|
<input type="text" placeholder="Sup?" value={note} onChange={(e) => setNote(e.target.value)}></input>
|
|
|
|
<div className="btn" onClick={() => sendNote()}>Send</div>
|
2022-12-18 14:51:47 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-12-28 16:29:42 +00:00
|
|
|
{pubKey ? noteSigner() : null}
|
2022-12-18 14:51:47 +00:00
|
|
|
<Timeline></Timeline>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|