2023-02-08 21:10:26 +00:00
|
|
|
import { FormattedMessage } from "react-intl";
|
2023-01-25 13:10:31 +00:00
|
|
|
import ProfilePreview from "Element/ProfilePreview";
|
|
|
|
import useRelayState from "Feed/RelayState";
|
|
|
|
import { System } from "Nostr/System";
|
|
|
|
import { useDispatch } from "react-redux";
|
|
|
|
import { useNavigate, useParams } from "react-router-dom";
|
|
|
|
import { removeRelay } from "State/Login";
|
2023-02-07 19:47:57 +00:00
|
|
|
import { parseId, unwrap } from "Util";
|
2023-01-25 13:10:31 +00:00
|
|
|
|
2023-02-08 21:10:26 +00:00
|
|
|
import messages from "./messages";
|
|
|
|
|
2023-01-25 13:10:31 +00:00
|
|
|
const RelayInfo = () => {
|
2023-02-07 20:04:50 +00:00
|
|
|
const params = useParams();
|
|
|
|
const navigate = useNavigate();
|
|
|
|
const dispatch = useDispatch();
|
2023-01-25 13:10:31 +00:00
|
|
|
|
2023-02-09 12:26:54 +00:00
|
|
|
const conn = Array.from(System.Sockets.values()).find(a => a.Id === params.id);
|
2023-02-07 20:04:50 +00:00
|
|
|
console.debug(conn);
|
|
|
|
const stats = useRelayState(conn?.Address ?? "");
|
2023-01-25 13:10:31 +00:00
|
|
|
|
2023-02-07 20:04:50 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h3 className="pointer" onClick={() => navigate("/settings/relays")}>
|
2023-02-08 21:10:26 +00:00
|
|
|
<FormattedMessage {...messages.Relays} />
|
2023-02-07 20:04:50 +00:00
|
|
|
</h3>
|
|
|
|
<div className="card">
|
|
|
|
<h3>{stats?.info?.name}</h3>
|
|
|
|
<p>{stats?.info?.description}</p>
|
2023-01-25 13:10:31 +00:00
|
|
|
|
2023-02-07 20:04:50 +00:00
|
|
|
{stats?.info?.pubkey && (
|
|
|
|
<>
|
2023-02-08 21:10:26 +00:00
|
|
|
<h4>
|
|
|
|
<FormattedMessage {...messages.Owner} />
|
|
|
|
</h4>
|
2023-02-07 20:04:50 +00:00
|
|
|
<ProfilePreview pubkey={parseId(stats.info.pubkey)} />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{stats?.info?.software && (
|
|
|
|
<div className="flex">
|
2023-02-08 21:10:26 +00:00
|
|
|
<h4 className="f-grow">
|
|
|
|
<FormattedMessage {...messages.Software} />
|
|
|
|
</h4>
|
2023-02-07 20:04:50 +00:00
|
|
|
<div className="flex f-col">
|
|
|
|
{stats.info.software.startsWith("http") ? (
|
|
|
|
<a href={stats.info.software} target="_blank" rel="noreferrer">
|
|
|
|
{stats.info.software}
|
|
|
|
</a>
|
|
|
|
) : (
|
|
|
|
<>{stats.info.software}</>
|
|
|
|
)}
|
|
|
|
<small>
|
|
|
|
{!stats.info.version?.startsWith("v") && "v"}
|
|
|
|
{stats.info.version}
|
|
|
|
</small>
|
2023-01-25 13:10:31 +00:00
|
|
|
</div>
|
2023-02-07 20:04:50 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{stats?.info?.contact && (
|
|
|
|
<div className="flex">
|
2023-02-08 21:10:26 +00:00
|
|
|
<h4 className="f-grow">
|
|
|
|
<FormattedMessage {...messages.Contact} />
|
|
|
|
</h4>
|
2023-02-07 20:04:50 +00:00
|
|
|
<a
|
2023-02-09 12:26:54 +00:00
|
|
|
href={`${stats.info.contact.startsWith("mailto:") ? "" : "mailto:"}${stats.info.contact}`}
|
2023-02-07 20:04:50 +00:00
|
|
|
target="_blank"
|
2023-02-09 12:26:54 +00:00
|
|
|
rel="noreferrer">
|
2023-02-07 20:04:50 +00:00
|
|
|
{stats.info.contact}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{stats?.info?.supported_nips && (
|
|
|
|
<>
|
2023-02-08 21:10:26 +00:00
|
|
|
<h4>
|
|
|
|
<FormattedMessage {...messages.Supports} />
|
|
|
|
</h4>
|
2023-02-07 20:04:50 +00:00
|
|
|
<div className="f-grow">
|
2023-02-09 12:26:54 +00:00
|
|
|
{stats.info.supported_nips.map(a => (
|
2023-02-07 20:04:50 +00:00
|
|
|
<span
|
|
|
|
className="pill"
|
|
|
|
onClick={() =>
|
2023-02-09 12:26:54 +00:00
|
|
|
navigate(`https://github.com/nostr-protocol/nips/blob/master/${a.toString().padStart(2, "0")}.md`)
|
|
|
|
}>
|
2023-02-07 20:04:50 +00:00
|
|
|
NIP-{a.toString().padStart(2, "0")}
|
|
|
|
</span>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
<div className="flex mt10 f-end">
|
|
|
|
<div
|
|
|
|
className="btn error"
|
|
|
|
onClick={() => {
|
2023-02-07 19:47:57 +00:00
|
|
|
dispatch(removeRelay(unwrap(conn).Address));
|
2023-02-07 20:04:50 +00:00
|
|
|
navigate("/settings/relays");
|
2023-02-09 12:26:54 +00:00
|
|
|
}}>
|
2023-02-08 21:10:26 +00:00
|
|
|
<FormattedMessage {...messages.Remove} />
|
2023-02-07 20:04:50 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2023-01-25 13:10:31 +00:00
|
|
|
|
2023-02-07 20:04:50 +00:00
|
|
|
export default RelayInfo;
|