summaryrefslogtreecommitdiff
path: root/front/src/components/post/wrappers/NostrIcon.tsx
blob: 30fbfe9b24d807b258ed24e17ff8732e806bebcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Icon from "@/components/Icon";
import useLocalState from "@/state/state";
import toast from "react-hot-toast";
import type { Poast } from "@/types/trill";
export default function ({ poast }: { poast: Poast }) {
  const { relays, api } = useLocalState((s) => ({
    relays: s.relays,
    api: s.api,
  }));

  async function sendToRelay(e: React.MouseEvent) {
    e.stopPropagation();
    //
    const urls = Object.keys(relays);
    await api!.relayPost(poast.host, poast.id, urls);
    toast.success("Post relayed");
  }
  // TODO round up all helpers

  return (
    <div className="icon" role="link" onMouseUp={sendToRelay}>
      <Icon name="nostr" size={20} title="relay to nostr" />
    </div>
  );
}