ProfileLink to /npub if profile not present
Some checks are pending
continuous-integration/drone/push Build is running
Some checks are pending
continuous-integration/drone/push Build is running
This commit is contained in:
parent
61e93bd194
commit
d2b95375b6
@ -7,14 +7,12 @@ import { randomSample } from "@/SnortUtils";
|
|||||||
export function ProfileLink({
|
export function ProfileLink({
|
||||||
pubkey,
|
pubkey,
|
||||||
user,
|
user,
|
||||||
link,
|
|
||||||
explicitLink,
|
explicitLink,
|
||||||
children,
|
children,
|
||||||
...others
|
...others
|
||||||
}: {
|
}: {
|
||||||
pubkey: string;
|
pubkey: string;
|
||||||
user?: UserMetadata | MetadataCache;
|
user?: UserMetadata | MetadataCache;
|
||||||
link?: NostrLink;
|
|
||||||
explicitLink?: string;
|
explicitLink?: string;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
} & Omit<LinkProps, "to">) {
|
} & Omit<LinkProps, "to">) {
|
||||||
@ -27,27 +25,21 @@ export function ProfileLink({
|
|||||||
if (explicitLink) {
|
if (explicitLink) {
|
||||||
return explicitLink;
|
return explicitLink;
|
||||||
}
|
}
|
||||||
if (user) {
|
if (
|
||||||
if (
|
user?.nip05 &&
|
||||||
user.nip05 &&
|
user.nip05.endsWith(`@${CONFIG.nip05Domain}`) &&
|
||||||
user.nip05.endsWith(`@${CONFIG.nip05Domain}`) &&
|
(!("isNostrAddressValid" in user) || user.isNostrAddressValid)
|
||||||
(!("isNostrAddressValid" in user) || user.isNostrAddressValid)
|
) {
|
||||||
) {
|
const [username] = user.nip05.split("@");
|
||||||
const [username] = user.nip05.split("@");
|
return `/${username}`;
|
||||||
return `/${username}`;
|
|
||||||
}
|
|
||||||
return `/${new NostrLink(
|
|
||||||
NostrPrefix.Profile,
|
|
||||||
pubkey,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
relays ? randomSample(relays, 3) : undefined,
|
|
||||||
).encode(CONFIG.profileLinkPrefix)}`;
|
|
||||||
}
|
}
|
||||||
if (link && (link.type === NostrPrefix.Profile || link.type === NostrPrefix.PublicKey)) {
|
return `/${new NostrLink(
|
||||||
return `/${link.encode()}`;
|
NostrPrefix.Profile,
|
||||||
}
|
pubkey,
|
||||||
return "#";
|
undefined,
|
||||||
|
undefined,
|
||||||
|
relays ? randomSample(relays, 3) : undefined,
|
||||||
|
).encode(CONFIG.profileLinkPrefix)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const oFiltered = others as Record<string, unknown>;
|
const oFiltered = others as Record<string, unknown>;
|
||||||
|
@ -24,7 +24,7 @@ import useFollowsFeed from "@/Feed/FollowsFeed";
|
|||||||
import useProfileBadges from "@/Feed/BadgesFeed";
|
import useProfileBadges from "@/Feed/BadgesFeed";
|
||||||
import useModeration from "@/Hooks/useModeration";
|
import useModeration from "@/Hooks/useModeration";
|
||||||
import FollowButton from "@/Element/User/FollowButton";
|
import FollowButton from "@/Element/User/FollowButton";
|
||||||
import { parseId, hexToBech32 } from "@/SnortUtils";
|
import { parseId } from "@/SnortUtils";
|
||||||
import Avatar from "@/Element/User/Avatar";
|
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";
|
||||||
@ -61,7 +61,6 @@ import { useMuteList, usePinList } from "@/Hooks/useLists";
|
|||||||
|
|
||||||
import messages from "../messages";
|
import messages from "../messages";
|
||||||
import FollowDistanceIndicator from "@/Element/User/FollowDistanceIndicator";
|
import FollowDistanceIndicator from "@/Element/User/FollowDistanceIndicator";
|
||||||
import classNames from "classnames";
|
|
||||||
import { ProfileLink } from "@/Element/User/ProfileLink";
|
import { ProfileLink } from "@/Element/User/ProfileLink";
|
||||||
|
|
||||||
interface ProfilePageProps {
|
interface ProfilePageProps {
|
||||||
@ -84,7 +83,6 @@ export default function ProfilePage({ id: propId, state }: ProfilePageProps) {
|
|||||||
const [showProfileQr, setShowProfileQr] = useState<boolean>(false);
|
const [showProfileQr, setShowProfileQr] = useState<boolean>(false);
|
||||||
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 lnurl = (() => {
|
const lnurl = (() => {
|
||||||
try {
|
try {
|
||||||
@ -168,22 +166,26 @@ export default function ProfilePage({ id: propId, state }: ProfilePageProps) {
|
|||||||
</h2>
|
</h2>
|
||||||
{user?.nip05 && <Nip05 nip05={user.nip05} pubkey={user.pubkey} />}
|
{user?.nip05 && <Nip05 nip05={user.nip05} pubkey={user.pubkey} />}
|
||||||
<div className="flex flex-row items-center">
|
<div className="flex flex-row items-center">
|
||||||
{user?.pubkey && <FollowDistanceIndicator className="p-2" pubkey={user.pubkey} />}
|
<div className="flex flex-row items-center">
|
||||||
|
{user?.pubkey && <FollowDistanceIndicator className="p-2" pubkey={user.pubkey} />}
|
||||||
|
{followedByFriendsArray.map((a, index) => {
|
||||||
|
const zIndex = followedByFriendsArray.length - index;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`inline-block ${index > 0 ? "-ml-5" : ""}`} key={a} style={{ zIndex }}>
|
||||||
|
<ProfileImage showFollowDistance={false} pubkey={a} size={24} showUsername={false} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
{followedByFriends.size > 0 && (
|
{followedByFriends.size > 0 && (
|
||||||
<div className="text-gray-light">
|
<div className="text-gray-light">
|
||||||
{followedByFriendsArray.map((a, index) => {
|
|
||||||
return (
|
|
||||||
<span className={classNames({ "-ml-4": index > 0 }, "inline-block")} key={a}>
|
|
||||||
<ProfileImage showFollowDistance={false} pubkey={a} size={24} showUsername={false} />
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
<span className="mr-1">
|
<span className="mr-1">
|
||||||
<FormattedMessage defaultMessage="Followed by" id="6mr8WU" />
|
<FormattedMessage defaultMessage="Followed by" id="6mr8WU" />
|
||||||
</span>
|
</span>
|
||||||
{followedByFriendsArray.map((a, index) => (
|
{followedByFriendsArray.map((a, index) => (
|
||||||
<Fragment key={a}>
|
<Fragment key={a}>
|
||||||
<ProfileLink pubkey={a} user={undefined} className="link inline">
|
<ProfileLink pubkey={a} className="link inline">
|
||||||
<DisplayName user={undefined} pubkey={a} />
|
<DisplayName user={undefined} pubkey={a} />
|
||||||
</ProfileLink>
|
</ProfileLink>
|
||||||
{index < followedByFriendsArray.length - 1 && ","}{" "}
|
{index < followedByFriendsArray.length - 1 && ","}{" "}
|
||||||
@ -204,9 +206,7 @@ export default function ProfilePage({ id: propId, state }: ProfilePageProps) {
|
|||||||
</div>
|
</div>
|
||||||
{showBadges && <BadgeList badges={badges} />}
|
{showBadges && <BadgeList badges={badges} />}
|
||||||
{showStatus && <>{musicStatus()}</>}
|
{showStatus && <>{musicStatus()}</>}
|
||||||
<div className="link-section">
|
<div className="link-section">{links()}</div>
|
||||||
{links()}
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -404,9 +404,6 @@
|
|||||||
"DZzCem": {
|
"DZzCem": {
|
||||||
"defaultMessage": "Show latest {n} notes"
|
"defaultMessage": "Show latest {n} notes"
|
||||||
},
|
},
|
||||||
"DcL8P+": {
|
|
||||||
"defaultMessage": "Supporter"
|
|
||||||
},
|
|
||||||
"Dh3hbq": {
|
"Dh3hbq": {
|
||||||
"defaultMessage": "Auto Zap"
|
"defaultMessage": "Auto Zap"
|
||||||
},
|
},
|
||||||
@ -537,6 +534,9 @@
|
|||||||
"IKKHqV": {
|
"IKKHqV": {
|
||||||
"defaultMessage": "Follows"
|
"defaultMessage": "Follows"
|
||||||
},
|
},
|
||||||
|
"IOu4Xh": {
|
||||||
|
"defaultMessage": "You must be a {tier} subscriber to access {app} deck"
|
||||||
|
},
|
||||||
"IVbtTS": {
|
"IVbtTS": {
|
||||||
"defaultMessage": "Zap all {n} sats"
|
"defaultMessage": "Zap all {n} sats"
|
||||||
},
|
},
|
||||||
@ -1525,6 +1525,9 @@
|
|||||||
"xmcVZ0": {
|
"xmcVZ0": {
|
||||||
"defaultMessage": "Search"
|
"defaultMessage": "Search"
|
||||||
},
|
},
|
||||||
|
"xybOUv": {
|
||||||
|
"defaultMessage": "FAN"
|
||||||
|
},
|
||||||
"y1Z3or": {
|
"y1Z3or": {
|
||||||
"defaultMessage": "Language"
|
"defaultMessage": "Language"
|
||||||
},
|
},
|
||||||
|
@ -133,7 +133,6 @@
|
|||||||
"DBiVK1": "Cache",
|
"DBiVK1": "Cache",
|
||||||
"DKnriN": "Send sats",
|
"DKnriN": "Send sats",
|
||||||
"DZzCem": "Show latest {n} notes",
|
"DZzCem": "Show latest {n} notes",
|
||||||
"DcL8P+": "Supporter",
|
|
||||||
"Dh3hbq": "Auto Zap",
|
"Dh3hbq": "Auto Zap",
|
||||||
"Dn82AL": "Live",
|
"Dn82AL": "Live",
|
||||||
"DtYelJ": "Transfer",
|
"DtYelJ": "Transfer",
|
||||||
@ -177,6 +176,7 @@
|
|||||||
"HhcAVH": "You don't follow this person, click here to load media from <i>{link}</i>, or update <a><i>your preferences</i></a> to always load media from everybody.",
|
"HhcAVH": "You don't follow this person, click here to load media from <i>{link}</i>, or update <a><i>your preferences</i></a> to always load media from everybody.",
|
||||||
"IEwZvs": "Are you sure you want to unpin this note?",
|
"IEwZvs": "Are you sure you want to unpin this note?",
|
||||||
"IKKHqV": "Follows",
|
"IKKHqV": "Follows",
|
||||||
|
"IOu4Xh": "You must be a {tier} subscriber to access {app} deck",
|
||||||
"IVbtTS": "Zap all {n} sats",
|
"IVbtTS": "Zap all {n} sats",
|
||||||
"IWz1ta": "Auto Translate",
|
"IWz1ta": "Auto Translate",
|
||||||
"Ig9/a1": "Sent {n} sats to {name}",
|
"Ig9/a1": "Sent {n} sats to {name}",
|
||||||
@ -502,6 +502,7 @@
|
|||||||
"xhQMeQ": "Expires",
|
"xhQMeQ": "Expires",
|
||||||
"xl4s/X": "Additional Terms:",
|
"xl4s/X": "Additional Terms:",
|
||||||
"xmcVZ0": "Search",
|
"xmcVZ0": "Search",
|
||||||
|
"xybOUv": "FAN",
|
||||||
"y1Z3or": "Language",
|
"y1Z3or": "Language",
|
||||||
"yCLnBC": "LNURL or Lightning Address",
|
"yCLnBC": "LNURL or Lightning Address",
|
||||||
"yNBPJp": "Help fund the development of {site}",
|
"yNBPJp": "Help fund the development of {site}",
|
||||||
|
Loading…
Reference in New Issue
Block a user