From e949708ceca60e3dc83a157b97351e18ce576c7c Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Fri, 6 Oct 2023 13:13:49 +0300 Subject: [PATCH 1/9] extract ProfileTab from ProfilePage --- .../src/Pages/{ => Profile}/ProfilePage.css | 0 .../src/Pages/{ => Profile}/ProfilePage.tsx | 170 ++---------------- packages/app/src/Pages/Profile/ProfileTab.tsx | 154 ++++++++++++++++ packages/app/src/index.tsx | 2 +- 4 files changed, 172 insertions(+), 154 deletions(-) rename packages/app/src/Pages/{ => Profile}/ProfilePage.css (100%) rename packages/app/src/Pages/{ => Profile}/ProfilePage.tsx (75%) create mode 100644 packages/app/src/Pages/Profile/ProfileTab.tsx diff --git a/packages/app/src/Pages/ProfilePage.css b/packages/app/src/Pages/Profile/ProfilePage.css similarity index 100% rename from packages/app/src/Pages/ProfilePage.css rename to packages/app/src/Pages/Profile/ProfilePage.css diff --git a/packages/app/src/Pages/ProfilePage.tsx b/packages/app/src/Pages/Profile/ProfilePage.tsx similarity index 75% rename from packages/app/src/Pages/ProfilePage.tsx rename to packages/app/src/Pages/Profile/ProfilePage.tsx index 5c2501ad..67ae1e62 100644 --- a/packages/app/src/Pages/ProfilePage.tsx +++ b/packages/app/src/Pages/Profile/ProfilePage.tsx @@ -6,8 +6,6 @@ import { encodeTLV, encodeTLVEntries, EventKind, - HexKey, - NostrLink, NostrPrefix, TLVEntryType, tryParseNostrLink, @@ -16,22 +14,14 @@ import { LNURL } from "@snort/shared"; import { useUserProfile } from "@snort/system-react"; import { findTag, getReactions, unwrap } from "SnortUtils"; -import { formatShort } from "Number"; import Note from "Element/Event/Note"; -import Bookmarks from "Element/Bookmarks"; -import RelaysMetadata from "Element/Relay/RelaysMetadata"; import { Tab, TabElement } from "Element/Tabs"; import Icon from "Icons/Icon"; import useMutedFeed from "Feed/MuteList"; -import useRelaysFeed from "Feed/RelaysFeed"; import usePinnedFeed from "Feed/PinnedFeed"; -import useBookmarkFeed from "Feed/BookmarkFeed"; -import useFollowersFeed from "Feed/FollowersFeed"; import useFollowsFeed from "Feed/FollowsFeed"; import useProfileBadges from "Feed/BadgesFeed"; import useModeration from "Hooks/useModeration"; -import useZapsFeed from "Feed/ZapsFeed"; -import { default as ZapElement } from "Element/Event/Zap"; import FollowButton from "Element/User/FollowButton"; import { parseId, hexToBech32 } from "SnortUtils"; import Avatar from "Element/User/Avatar"; @@ -57,59 +47,16 @@ import useLogin from "Hooks/useLogin"; import { ZapTarget } from "Zapper"; import { useStatusFeed } from "Feed/StatusFeed"; -import messages from "./messages"; +import messages from "../messages"; import { SpotlightMediaModal } from "Element/Deck/SpotlightMedia"; - -const NOTES = 0; -const REACTIONS = 1; -const FOLLOWERS = 2; -const FOLLOWS = 3; -const ZAPS = 4; -const MUTED = 5; -const BLOCKED = 6; -const RELAYS = 7; -const BOOKMARKS = 8; - -function ZapsProfileTab({ id }: { id: HexKey }) { - const zaps = useZapsFeed(new NostrLink(NostrPrefix.PublicKey, id)); - const zapsTotal = zaps.reduce((acc, z) => acc + z.amount, 0); - return ( -
-

- -

- {zaps.map(z => ( - - ))} -
- ); -} - -function FollowersTab({ id }: { id: HexKey }) { - const followers = useFollowersFeed(id); - return ; -} - -function FollowsTab({ id }: { id: HexKey }) { - const follows = useFollowsFeed(id); - return ; -} - -function RelaysTab({ id }: { id: HexKey }) { - const relays = useRelaysFeed(id); - return ; -} - -function BookMarksTab({ id }: { id: HexKey }) { - const bookmarks = useBookmarkFeed(id); - return ( - e.kind === EventKind.TextNote)} - related={bookmarks.filter(e => e.kind !== EventKind.TextNote)} - /> - ); -} +import ProfileTab, { + BookMarksTab, + FollowersTab, + FollowsTab, + ProfileTabType, + RelaysTab, + ZapsProfileTab +} from "Pages/Profile/ProfileTab"; export default function ProfilePage() { const params = useParams(); @@ -146,89 +93,6 @@ export default function ProfilePage() { const status = useStatusFeed(showStatus ? id : undefined, true); // tabs - const ProfileTab = { - Notes: { - text: ( - <> - - - - ), - value: NOTES, - }, - Reactions: { - text: ( - <> - - - - ), - value: REACTIONS, - }, - Followers: { - text: ( - <> - - - - ), - value: FOLLOWERS, - }, - Follows: { - text: ( - <> - - - - ), - value: FOLLOWS, - }, - Zaps: { - text: ( - <> - - - - ), - value: ZAPS, - }, - Muted: { - text: ( - <> - - - - ), - value: MUTED, - }, - Blocked: { - text: ( - <> - - - - ), - value: BLOCKED, - }, - Relays: { - text: ( - <> - - - - ), - value: RELAYS, - }, - Bookmarks: { - text: ( - <> - - - - ), - value: BOOKMARKS, - }, - } as { [key: string]: Tab }; const [tab, setTab] = useState(ProfileTab.Notes); const optionalTabs = [ProfileTab.Zaps, ProfileTab.Relays, ProfileTab.Bookmarks, ProfileTab.Muted].filter(a => unwrap(a), @@ -369,7 +233,7 @@ export default function ProfilePage() { if (!id) return null; switch (tab.value) { - case NOTES: + case ProfileTabType.NOTES: return ( <> {pinned @@ -399,29 +263,29 @@ export default function ProfilePage() { /> ); - case ZAPS: { + case ProfileTabType.ZAPS: { return ; } - case FOLLOWS: { + case ProfileTabType.FOLLOWS: { if (isMe) { return ; } else { return ; } } - case FOLLOWERS: { + case ProfileTabType.FOLLOWERS: { return ; } - case MUTED: { + case ProfileTabType.MUTED: { return ; } - case BLOCKED: { + case ProfileTabType.BLOCKED: { return ; } - case RELAYS: { + case ProfileTabType.RELAYS: { return ; } - case BOOKMARKS: { + case ProfileTabType.BOOKMARKS: { return ; } } diff --git a/packages/app/src/Pages/Profile/ProfileTab.tsx b/packages/app/src/Pages/Profile/ProfileTab.tsx new file mode 100644 index 00000000..f4e53478 --- /dev/null +++ b/packages/app/src/Pages/Profile/ProfileTab.tsx @@ -0,0 +1,154 @@ +import useZapsFeed from "../../Feed/ZapsFeed"; +import FormattedMessage from "../../Element/FormattedMessage"; +import messages from "../messages"; +import {formatShort} from "../../Number"; +import useFollowersFeed from "../../Feed/FollowersFeed"; +import FollowsList from "../../Element/User/FollowListBase"; +import useFollowsFeed from "../../Feed/FollowsFeed"; +import useRelaysFeed from "../../Feed/RelaysFeed"; +import RelaysMetadata from "../../Element/Relay/RelaysMetadata"; +import useBookmarkFeed from "../../Feed/BookmarkFeed"; +import Bookmarks from "../../Element/Bookmarks"; +import Icon from "../../Icons/Icon"; +import {Tab} from "../../Element/Tabs"; +import {EventKind, HexKey, NostrLink, NostrPrefix} from "@snort/system"; +import { default as ZapElement } from "Element/Event/Zap"; + +export enum ProfileTabType { + NOTES = 0, + REACTIONS = 1, + FOLLOWERS = 2, + FOLLOWS = 3, + ZAPS = 4, + MUTED = 5, + BLOCKED = 6, + RELAYS = 7, + BOOKMARKS = 8, +} + +export function ZapsProfileTab({ id }: { id: HexKey }) { + const zaps = useZapsFeed(new NostrLink(NostrPrefix.PublicKey, id)); + const zapsTotal = zaps.reduce((acc, z) => acc + z.amount, 0); + return ( +
+

+ +

+ {zaps.map(z => ( + + ))} +
+ ); +} + +export function FollowersTab({ id }: { id: HexKey }) { + const followers = useFollowersFeed(id); + return ; +} + +export function FollowsTab({ id }: { id: HexKey }) { + const follows = useFollowsFeed(id); + return ; +} + +export function RelaysTab({ id }: { id: HexKey }) { + const relays = useRelaysFeed(id); + return ; +} + +export function BookMarksTab({ id }: { id: HexKey }) { + const bookmarks = useBookmarkFeed(id); + return ( + e.kind === EventKind.TextNote)} + related={bookmarks.filter(e => e.kind !== EventKind.TextNote)} + /> + ); +} + +const ProfileTab = { + Notes: { + text: ( + <> + + + + ), + value: ProfileTabType.NOTES, + }, + Reactions: { + text: ( + <> + + + + ), + value: ProfileTabType.REACTIONS, + }, + Followers: { + text: ( + <> + + + + ), + value: ProfileTabType.FOLLOWERS, + }, + Follows: { + text: ( + <> + + + + ), + value: ProfileTabType.FOLLOWS, + }, + Zaps: { + text: ( + <> + + + + ), + value: ProfileTabType.ZAPS, + }, + Muted: { + text: ( + <> + + + + ), + value: ProfileTabType.MUTED, + }, + Blocked: { + text: ( + <> + + + + ), + value: ProfileTabType.BLOCKED, + }, + Relays: { + text: ( + <> + + + + ), + value: ProfileTabType.RELAYS, + }, + Bookmarks: { + text: ( + <> + + + + ), + value: ProfileTabType.BOOKMARKS, + }, + } as { [key: string]: Tab }; + +export default ProfileTab; \ No newline at end of file diff --git a/packages/app/src/index.tsx b/packages/app/src/index.tsx index 35b5d009..8b599091 100644 --- a/packages/app/src/index.tsx +++ b/packages/app/src/index.tsx @@ -24,7 +24,7 @@ import { IntlProvider } from "IntlProvider"; import { unwrap } from "SnortUtils"; import Layout from "Pages/Layout"; import LoginPage from "Pages/LoginPage"; -import ProfilePage from "Pages/ProfilePage"; +import ProfilePage from "Pages/Profile/ProfilePage"; import { RootRoutes, RootTabRoutes } from "Pages/Root"; import NotificationsPage from "Pages/Notifications"; import SettingsPage, { SettingsRoutes } from "Pages/SettingsPage"; -- 2.45.2 From 9f5d467745d29cfa3cbf601cccf3d9b9a32975a9 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Fri, 6 Oct 2023 14:06:12 +0300 Subject: [PATCH 2/9] body overflow-y: scroll to reduce layout shift --- packages/app/src/index.css | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/app/src/index.css b/packages/app/src/index.css index a038ce28..daabc122 100644 --- a/packages/app/src/index.css +++ b/packages/app/src/index.css @@ -105,6 +105,7 @@ body { color: var(--font-color); font-size: var(--font-size); overflow-x: hidden; + overflow-y: scroll; } code { -- 2.45.2 From 3f7ac9e2d4518ef419a018f63110c442c64b0edd Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Fri, 6 Oct 2023 15:03:18 +0300 Subject: [PATCH 3/9] if username@{NIP05_DOMAIN} valid, change profile page url to /username --- .../app/src/Pages/Profile/ProfilePage.tsx | 33 +++- packages/app/src/Pages/Profile/ProfileTab.tsx | 172 +++++++++--------- 2 files changed, 109 insertions(+), 96 deletions(-) diff --git a/packages/app/src/Pages/Profile/ProfilePage.tsx b/packages/app/src/Pages/Profile/ProfilePage.tsx index 67ae1e62..da23fc3e 100644 --- a/packages/app/src/Pages/Profile/ProfilePage.tsx +++ b/packages/app/src/Pages/Profile/ProfilePage.tsx @@ -2,14 +2,7 @@ import "./ProfilePage.css"; import { useEffect, useState } from "react"; import FormattedMessage from "Element/FormattedMessage"; import { useNavigate, useParams } from "react-router-dom"; -import { - encodeTLV, - encodeTLVEntries, - EventKind, - NostrPrefix, - TLVEntryType, - tryParseNostrLink, -} from "@snort/system"; +import { encodeTLV, encodeTLVEntries, EventKind, NostrPrefix, TLVEntryType, tryParseNostrLink } from "@snort/system"; import { LNURL } from "@snort/shared"; import { useUserProfile } from "@snort/system-react"; @@ -28,7 +21,7 @@ import Avatar from "Element/User/Avatar"; import Timeline from "Element/Feed/Timeline"; import Text from "Element/Text"; import SendSats from "Element/SendSats"; -import Nip05 from "Element/User/Nip05"; +import Nip05, { useIsVerified } from "Element/User/Nip05"; import Copy from "Element/Copy"; import ProfileImage from "Element/User/ProfileImage"; import BlockList from "Element/User/BlockList"; @@ -55,7 +48,7 @@ import ProfileTab, { FollowsTab, ProfileTabType, RelaysTab, - ZapsProfileTab + ZapsProfileTab, } from "Pages/Profile/ProfileTab"; export default function ProfilePage() { @@ -71,6 +64,7 @@ export default function ProfilePage() { const [modalImage, setModalImage] = useState(""); const aboutText = user?.about || ""; const npub = !id?.startsWith(NostrPrefix.PublicKey) ? hexToBech32(NostrPrefix.PublicKey, id || undefined) : id; + const { isVerified } = useIsVerified(user?.pubkey || ""); const lnurl = (() => { try { @@ -139,6 +133,25 @@ export default function ProfilePage() { return inner(); } + useEffect(() => { + const replaceWith = (username: string) => { + 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}`)) { + const username = user.nip05?.replace(`@${process.env.NIP05_DOMAIN}`, ""); + replaceWith(username); + } else { + // do we want this? would need to support urls with dots like /fiatjaf.com + // replaceWith(user.nip05?.replace(/^_@/, "")); + } + } + }, [isVerified, user?.pubkey]); + function username() { return ( <> diff --git a/packages/app/src/Pages/Profile/ProfileTab.tsx b/packages/app/src/Pages/Profile/ProfileTab.tsx index f4e53478..c03a536a 100644 --- a/packages/app/src/Pages/Profile/ProfileTab.tsx +++ b/packages/app/src/Pages/Profile/ProfileTab.tsx @@ -1,7 +1,7 @@ import useZapsFeed from "../../Feed/ZapsFeed"; import FormattedMessage from "../../Element/FormattedMessage"; import messages from "../messages"; -import {formatShort} from "../../Number"; +import { formatShort } from "../../Number"; import useFollowersFeed from "../../Feed/FollowersFeed"; import FollowsList from "../../Element/User/FollowListBase"; import useFollowsFeed from "../../Feed/FollowsFeed"; @@ -10,8 +10,8 @@ import RelaysMetadata from "../../Element/Relay/RelaysMetadata"; import useBookmarkFeed from "../../Feed/BookmarkFeed"; import Bookmarks from "../../Element/Bookmarks"; import Icon from "../../Icons/Icon"; -import {Tab} from "../../Element/Tabs"; -import {EventKind, HexKey, NostrLink, NostrPrefix} from "@snort/system"; +import { Tab } from "../../Element/Tabs"; +import { EventKind, HexKey, NostrLink, NostrPrefix } from "@snort/system"; import { default as ZapElement } from "Element/Event/Zap"; export enum ProfileTabType { @@ -68,87 +68,87 @@ export function BookMarksTab({ id }: { id: HexKey }) { } const ProfileTab = { - Notes: { - text: ( - <> - - - - ), - value: ProfileTabType.NOTES, - }, - Reactions: { - text: ( - <> - - - - ), - value: ProfileTabType.REACTIONS, - }, - Followers: { - text: ( - <> - - - - ), - value: ProfileTabType.FOLLOWERS, - }, - Follows: { - text: ( - <> - - - - ), - value: ProfileTabType.FOLLOWS, - }, - Zaps: { - text: ( - <> - - - - ), - value: ProfileTabType.ZAPS, - }, - Muted: { - text: ( - <> - - - - ), - value: ProfileTabType.MUTED, - }, - Blocked: { - text: ( - <> - - - - ), - value: ProfileTabType.BLOCKED, - }, - Relays: { - text: ( - <> - - - - ), - value: ProfileTabType.RELAYS, - }, - Bookmarks: { - text: ( - <> - - - - ), - value: ProfileTabType.BOOKMARKS, - }, - } as { [key: string]: Tab }; + Notes: { + text: ( + <> + + + + ), + value: ProfileTabType.NOTES, + }, + Reactions: { + text: ( + <> + + + + ), + value: ProfileTabType.REACTIONS, + }, + Followers: { + text: ( + <> + + + + ), + value: ProfileTabType.FOLLOWERS, + }, + Follows: { + text: ( + <> + + + + ), + value: ProfileTabType.FOLLOWS, + }, + Zaps: { + text: ( + <> + + + + ), + value: ProfileTabType.ZAPS, + }, + Muted: { + text: ( + <> + + + + ), + value: ProfileTabType.MUTED, + }, + Blocked: { + text: ( + <> + + + + ), + value: ProfileTabType.BLOCKED, + }, + Relays: { + text: ( + <> + + + + ), + value: ProfileTabType.RELAYS, + }, + Bookmarks: { + text: ( + <> + + + + ), + value: ProfileTabType.BOOKMARKS, + }, +} as { [key: string]: Tab }; -export default ProfileTab; \ No newline at end of file +export default ProfileTab; -- 2.45.2 From 5ed096509aa57ff1c042033934bfa575ff3402e4 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Sun, 8 Oct 2023 15:27:41 +0300 Subject: [PATCH 4/9] use DisplayName on profile page --- packages/app/src/Pages/Profile/ProfilePage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/app/src/Pages/Profile/ProfilePage.tsx b/packages/app/src/Pages/Profile/ProfilePage.tsx index da23fc3e..1a1320a1 100644 --- a/packages/app/src/Pages/Profile/ProfilePage.tsx +++ b/packages/app/src/Pages/Profile/ProfilePage.tsx @@ -50,6 +50,7 @@ import ProfileTab, { RelaysTab, ZapsProfileTab, } from "Pages/Profile/ProfileTab"; +import DisplayName from "../../Element/User/DisplayName"; export default function ProfilePage() { const params = useParams(); @@ -157,7 +158,7 @@ export default function ProfilePage() { <>

- {user?.display_name || user?.name || "Nostrich"} +

{user?.nip05 && } -- 2.45.2 From 091169ae7da89bf5617134380b26f59c08fc28d4 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Sun, 8 Oct 2023 16:21:56 +0300 Subject: [PATCH 5/9] return note or profile component directly from NostrLinkHandler --- packages/app/src/Element/Event/Thread.tsx | 5 +++-- packages/app/src/Pages/NostrLinkHandler.tsx | 19 ++++++++++++------- .../app/src/Pages/Profile/ProfilePage.tsx | 17 +++++++++++------ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/app/src/Element/Event/Thread.tsx b/packages/app/src/Element/Event/Thread.tsx index 6fd8192c..20ccb721 100644 --- a/packages/app/src/Element/Event/Thread.tsx +++ b/packages/app/src/Element/Event/Thread.tsx @@ -205,9 +205,10 @@ const TierThree = ({ active, isLastSubthread, notes, related, chains, onNavigate ); }; -export function ThreadRoute() { +export function ThreadRoute({ id }: { id?: string }) { const params = useParams(); - const link = parseNostrLink(params.id ?? "", NostrPrefix.Note); + const resolvedId = id ?? params.id; + const link = parseNostrLink(resolvedId ?? "", NostrPrefix.Note); return ( diff --git a/packages/app/src/Pages/NostrLinkHandler.tsx b/packages/app/src/Pages/NostrLinkHandler.tsx index 99217d26..801ab794 100644 --- a/packages/app/src/Pages/NostrLinkHandler.tsx +++ b/packages/app/src/Pages/NostrLinkHandler.tsx @@ -1,32 +1,33 @@ import { NostrPrefix, tryParseNostrLink } from "@snort/system"; import { useEffect, useState } from "react"; import FormattedMessage from "Element/FormattedMessage"; -import { useNavigate, useParams } from "react-router-dom"; +import { useParams } from "react-router-dom"; import Spinner from "Icons/Spinner"; -import { profileLink } from "SnortUtils"; import { getNip05PubKey } from "Pages/LoginPage"; +import ProfilePage from "Pages/Profile/ProfilePage"; +import { ThreadRoute } from "Element/Event/Thread"; export default function NostrLinkHandler() { const params = useParams(); - const navigate = useNavigate(); - const [loading, setLoading] = useState(true); + const [renderComponent, setRenderComponent] = useState(null); + const link = decodeURIComponent(params["*"] ?? "").toLowerCase(); async function handleLink(link: string) { const nav = tryParseNostrLink(link); if (nav) { if (nav.type === NostrPrefix.Event || nav.type === NostrPrefix.Note || nav.type === NostrPrefix.Address) { - navigate(`/e/${nav.encode()}`); + setRenderComponent(); // Directly render ThreadRoute } else if (nav.type === NostrPrefix.PublicKey || nav.type === NostrPrefix.Profile) { - navigate(`/p/${nav.encode()}`); + setRenderComponent(); // Directly render ProfilePage } } else { try { const pubkey = await getNip05PubKey(`${link}@${process.env.NIP05_DOMAIN}`); if (pubkey) { - navigate(profileLink(pubkey)); + setRenderComponent(); // Directly render ProfilePage } } catch { //ignored @@ -41,6 +42,10 @@ export default function NostrLinkHandler() { } }, [link]); + if (renderComponent) { + return renderComponent; + } + return (
{loading ? ( diff --git a/packages/app/src/Pages/Profile/ProfilePage.tsx b/packages/app/src/Pages/Profile/ProfilePage.tsx index 1a1320a1..d0833a93 100644 --- a/packages/app/src/Pages/Profile/ProfilePage.tsx +++ b/packages/app/src/Pages/Profile/ProfilePage.tsx @@ -52,7 +52,11 @@ import ProfileTab, { } from "Pages/Profile/ProfileTab"; import DisplayName from "../../Element/User/DisplayName"; -export default function ProfilePage() { +interface ProfilePageProps { + id?: string; +} + +export default function ProfilePage({ id: propId }: ProfilePageProps) { const params = useParams(); const navigate = useNavigate(); const [id, setId] = useState(); @@ -95,21 +99,22 @@ export default function ProfilePage() { const horizontalScroll = useHorizontalScroll(); useEffect(() => { - if (params.id?.match(EmailRegex)) { - getNip05PubKey(params.id).then(a => { + const resolvedId = propId || params.id; + if (resolvedId?.match(EmailRegex)) { + getNip05PubKey(resolvedId).then(a => { setId(a); }); } else { - const nav = tryParseNostrLink(params.id ?? ""); + const nav = tryParseNostrLink(resolvedId ?? ""); if (nav?.type === NostrPrefix.PublicKey || nav?.type === NostrPrefix.Profile) { // todo: use relays if any for nprofile setId(nav.id); } else { - setId(parseId(params.id ?? "")); + setId(parseId(resolvedId ?? "")); } } setTab(ProfileTab.Notes); - }, [params]); + }, [propId, params]); function musicStatus() { if (!status.music) return; -- 2.45.2 From 224960a11f476c428b959a05f1721a2675c2bdd1 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Sun, 8 Oct 2023 16:40:23 +0300 Subject: [PATCH 6/9] add spacing before media and link embeds --- packages/app/src/Element/Text.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/app/src/Element/Text.tsx b/packages/app/src/Element/Text.tsx index 31fea6dc..c96640c5 100644 --- a/packages/app/src/Element/Text.tsx +++ b/packages/app/src/Element/Text.tsx @@ -170,6 +170,9 @@ export default function Text({ } if (element.type === "media" && element.mimeType?.startsWith("image")) { + if (i > 0) { + chunks.push(
); + } if (disableMedia ?? false) { chunks.push(); } else { @@ -231,6 +234,9 @@ export default function Text({ element.type === "media" && (element.mimeType?.startsWith("audio") || element.mimeType?.startsWith("video")) ) { + if (i > 0) { + chunks.push(
); + } if (disableMedia ?? false) { chunks.push(); } else { @@ -247,6 +253,9 @@ export default function Text({ chunks.push(); } if (element.type === "link" || (element.type === "media" && element.mimeType?.startsWith("unknown"))) { + if (i > 0 && !disableLinkPreview) { + chunks.push(
); + } chunks.push( , ); -- 2.45.2 From 79ef1470234b167454cc0b7db6295aa117a6bee3 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Mon, 9 Oct 2023 15:44:47 +0300 Subject: [PATCH 7/9] simpler profile url nip05 replacement --- .../app/src/Pages/Profile/ProfilePage.tsx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/packages/app/src/Pages/Profile/ProfilePage.tsx b/packages/app/src/Pages/Profile/ProfilePage.tsx index d0833a93..96d2da78 100644 --- a/packages/app/src/Pages/Profile/ProfilePage.tsx +++ b/packages/app/src/Pages/Profile/ProfilePage.tsx @@ -21,7 +21,7 @@ import Avatar from "Element/User/Avatar"; import Timeline from "Element/Feed/Timeline"; import Text from "Element/Text"; import SendSats from "Element/SendSats"; -import Nip05, { useIsVerified } from "Element/User/Nip05"; +import Nip05 from "Element/User/Nip05"; import Copy from "Element/Copy"; import ProfileImage from "Element/User/ProfileImage"; import BlockList from "Element/User/BlockList"; @@ -69,7 +69,6 @@ export default function ProfilePage({ id: propId }: ProfilePageProps) { const [modalImage, setModalImage] = useState(""); const aboutText = user?.about || ""; const npub = !id?.startsWith(NostrPrefix.PublicKey) ? hexToBech32(NostrPrefix.PublicKey, id || undefined) : id; - const { isVerified } = useIsVerified(user?.pubkey || ""); const lnurl = (() => { try { @@ -140,23 +139,13 @@ export default function ProfilePage({ id: propId }: ProfilePageProps) { } useEffect(() => { - const replaceWith = (username: string) => { - 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 && user?.isNostrAddressValid) { if (user.nip05.endsWith(`@${process.env.NIP05_DOMAIN}`)) { const username = user.nip05?.replace(`@${process.env.NIP05_DOMAIN}`, ""); - replaceWith(username); - } else { - // do we want this? would need to support urls with dots like /fiatjaf.com - // replaceWith(user.nip05?.replace(/^_@/, "")); + navigate(`/${username}`, { replace: true }); } } - }, [isVerified, user?.pubkey]); + }, [user?.isNostrAddressValid, user?.nip05]); function username() { return ( -- 2.45.2 From dbaad8bbb335a49899103a4bc5c817851cbb7069 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Mon, 9 Oct 2023 15:58:01 +0300 Subject: [PATCH 8/9] make useIsVerified pubkey param optional --- packages/app/src/Element/User/Nip05.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/src/Element/User/Nip05.tsx b/packages/app/src/Element/User/Nip05.tsx index 2f9da25a..be43cee5 100644 --- a/packages/app/src/Element/User/Nip05.tsx +++ b/packages/app/src/Element/User/Nip05.tsx @@ -2,7 +2,7 @@ import "./Nip05.css"; import { HexKey } from "@snort/system"; import { useUserProfile } from "@snort/system-react"; -export function useIsVerified(pubkey: HexKey, bypassCheck?: boolean) { +export function useIsVerified(pubkey?: HexKey, bypassCheck?: boolean) { const profile = useUserProfile(pubkey); return { isVerified: bypassCheck || profile?.isNostrAddressValid }; } -- 2.45.2 From 15fb4cabdf4b838522d42ffedf96c30bc2076dc9 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Mon, 9 Oct 2023 16:06:47 +0300 Subject: [PATCH 9/9] css selector based margin-top --- packages/app/src/Element/Text.css | 4 ++++ packages/app/src/Element/Text.tsx | 9 --------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/app/src/Element/Text.css b/packages/app/src/Element/Text.css index 4a458edb..8dbbbffe 100644 --- a/packages/app/src/Element/Text.css +++ b/packages/app/src/Element/Text.css @@ -113,3 +113,7 @@ height: 100%; display: block; } + +.gallery:not(:first-child), img:not(:first-child), video:not(:first-child), .link-preview-container:not(:first-child) { + margin-top: 10px; +} \ No newline at end of file diff --git a/packages/app/src/Element/Text.tsx b/packages/app/src/Element/Text.tsx index c96640c5..31fea6dc 100644 --- a/packages/app/src/Element/Text.tsx +++ b/packages/app/src/Element/Text.tsx @@ -170,9 +170,6 @@ export default function Text({ } if (element.type === "media" && element.mimeType?.startsWith("image")) { - if (i > 0) { - chunks.push(
); - } if (disableMedia ?? false) { chunks.push(); } else { @@ -234,9 +231,6 @@ export default function Text({ element.type === "media" && (element.mimeType?.startsWith("audio") || element.mimeType?.startsWith("video")) ) { - if (i > 0) { - chunks.push(
); - } if (disableMedia ?? false) { chunks.push(); } else { @@ -253,9 +247,6 @@ export default function Text({ chunks.push(); } if (element.type === "link" || (element.type === "media" && element.mimeType?.startsWith("unknown"))) { - if (i > 0 && !disableLinkPreview) { - chunks.push(
); - } chunks.push( , ); -- 2.45.2