simpler profile url nip05 replacement
This commit is contained in:
parent
224960a11f
commit
79ef147023
@ -21,7 +21,7 @@ import Avatar from "Element/User/Avatar";
|
|||||||
import Timeline from "Element/Feed/Timeline";
|
import Timeline from "Element/Feed/Timeline";
|
||||||
import Text from "Element/Text";
|
import Text from "Element/Text";
|
||||||
import SendSats from "Element/SendSats";
|
import SendSats from "Element/SendSats";
|
||||||
import Nip05, { useIsVerified } from "Element/User/Nip05";
|
import Nip05 from "Element/User/Nip05";
|
||||||
import Copy from "Element/Copy";
|
import Copy from "Element/Copy";
|
||||||
import ProfileImage from "Element/User/ProfileImage";
|
import ProfileImage from "Element/User/ProfileImage";
|
||||||
import BlockList from "Element/User/BlockList";
|
import BlockList from "Element/User/BlockList";
|
||||||
@ -69,7 +69,6 @@ export default function ProfilePage({ id: propId }: ProfilePageProps) {
|
|||||||
const [modalImage, setModalImage] = useState<string>("");
|
const [modalImage, setModalImage] = useState<string>("");
|
||||||
const aboutText = user?.about || "";
|
const aboutText = user?.about || "";
|
||||||
const npub = !id?.startsWith(NostrPrefix.PublicKey) ? hexToBech32(NostrPrefix.PublicKey, id || undefined) : id;
|
const npub = !id?.startsWith(NostrPrefix.PublicKey) ? hexToBech32(NostrPrefix.PublicKey, id || undefined) : id;
|
||||||
const { isVerified } = useIsVerified(user?.pubkey || "");
|
|
||||||
|
|
||||||
const lnurl = (() => {
|
const lnurl = (() => {
|
||||||
try {
|
try {
|
||||||
@ -140,23 +139,13 @@ export default function ProfilePage({ id: propId }: ProfilePageProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const replaceWith = (username: string) => {
|
if (user?.nip05 && user?.isNostrAddressValid) {
|
||||||
const current = window.location.pathname;
|
|
||||||
const npub = hexToBech32(NostrPrefix.PublicKey, user?.pubkey);
|
|
||||||
if (current.endsWith(`/${npub}`)) {
|
|
||||||
window.history.replaceState?.(null, "", `/${username}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (user?.nip05) {
|
|
||||||
if (user.nip05.endsWith(`@${process.env.NIP05_DOMAIN}`)) {
|
if (user.nip05.endsWith(`@${process.env.NIP05_DOMAIN}`)) {
|
||||||
const username = user.nip05?.replace(`@${process.env.NIP05_DOMAIN}`, "");
|
const username = user.nip05?.replace(`@${process.env.NIP05_DOMAIN}`, "");
|
||||||
replaceWith(username);
|
navigate(`/${username}`, { replace: true });
|
||||||
} else {
|
|
||||||
// do we want this? would need to support urls with dots like /fiatjaf.com
|
|
||||||
// replaceWith(user.nip05?.replace(/^_@/, ""));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isVerified, user?.pubkey]);
|
}, [user?.isNostrAddressValid, user?.nip05]);
|
||||||
|
|
||||||
function username() {
|
function username() {
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user