feat: profile link to short url

This commit is contained in:
2024-05-13 16:31:17 +01:00
parent caddf9a388
commit b988a73e36
5 changed files with 20 additions and 12 deletions

View File

@ -5,7 +5,6 @@ import { Link, Outlet, useLocation, useNavigate, useParams } from "react-router-
import { Helmet } from "react-helmet";
import { FormattedMessage, useIntl } from "react-intl";
import { Menu, MenuItem } from "@szhsin/react-menu";
import { hexToBech32 } from "@snort/shared";
import { Icon } from "@/element/icon";
import { useLogin, useLoginEvents } from "@/hooks/login";
@ -14,7 +13,7 @@ import { LoginSignup } from "@/element/login-signup";
import { Login } from "@/login";
import { useLang } from "@/hooks/lang";
import { AllLocales } from "@/intl";
import { trackEvent } from "@/utils";
import { profileLink, trackEvent } from "@/utils";
import { BorderButton, DefaultButton } from "@/element/buttons";
import Modal from "@/element/modal";
import Logo from "@/element/logo";
@ -89,7 +88,7 @@ export function LayoutPage() {
}
align="end"
gap={5}>
<MenuItem onClick={() => navigate(`/p/${hexToBech32("npub", login.pubkey)}`)}>
<MenuItem onClick={() => navigate(profileLink(undefined, login.pubkey))}>
<Icon name="user" size={24} />
<FormattedMessage defaultMessage="Profile" id="itPgxd" />
</MenuItem>

View File

@ -1,7 +1,7 @@
import "./profile-page.css";
import { useMemo } from "react";
import { Link, useNavigate, useParams } from "react-router-dom";
import { CachedMetadata, NostrEvent, NostrLink, NostrPrefix, TaggedNostrEvent, parseNostrLink } from "@snort/system";
import { CachedMetadata, NostrEvent, NostrLink, TaggedNostrEvent, parseNostrLink } from "@snort/system";
import { useUserProfile } from "@snort/system-react";
import { unwrap } from "@snort/shared";
import { FormattedMessage } from "react-intl";
@ -13,7 +13,7 @@ import { FollowButton } from "@/element/follow-button";
import { MuteButton } from "@/element/mute-button";
import { useProfile } from "@/hooks/profile";
import { Text } from "@/element/text";
import { findTag } from "@/utils";
import { findTag, profileLink } from "@/utils";
import { StatePill } from "@/element/state-pill";
import { Avatar } from "@/element/avatar";
import { StreamState } from "@/const";
@ -198,7 +198,7 @@ function ProfileClip({ ev }: { ev: NostrEvent }) {
values={{
name: (
<Link
to={`/p/${new NostrLink(NostrPrefix.PublicKey, ev.pubkey).encode()}`}
to={profileLink(profile, ev.pubkey)}
className="font-medium text-primary">
{getName(ev.pubkey, profile)}
</Link>