diff --git a/packages/app/src/Pages/Profile/AvatarSection.tsx b/packages/app/src/Pages/Profile/AvatarSection.tsx index ea6c7411..71b654e9 100644 --- a/packages/app/src/Pages/Profile/AvatarSection.tsx +++ b/packages/app/src/Pages/Profile/AvatarSection.tsx @@ -1,7 +1,7 @@ import { LNURL } from "@snort/shared"; import { CachedMetadata, encodeTLVEntries, NostrPrefix, TLVEntryType } from "@snort/system"; import React, { useMemo, useState } from "react"; -import { FormattedMessage } from "react-intl"; +import { FormattedMessage, useIntl } from "react-intl"; import { Link, useNavigate } from "react-router-dom"; import IconButton from "@/Components/Button/IconButton"; @@ -14,6 +14,7 @@ import FollowButton from "@/Components/User/FollowButton"; import ProfileImage from "@/Components/User/ProfileImage"; import ZapModal from "@/Components/ZapModal/ZapModal"; import { hexToBech32 } from "@/Utils"; +import { LoginSessionType, LoginStore } from "@/Utils/Login"; const AvatarSection = ({ user, @@ -34,6 +35,8 @@ const AvatarSection = ({ const profileId = useMemo(() => hexToBech32(CONFIG.profileLinkPrefix, id), [id]); const navigate = useNavigate(); const isMe = loginPubKey === id; + const canWrite = !!loginPubKey && !readonly; + const intl = useIntl(); const renderButtons = () => { if (!id) return null; @@ -66,7 +69,7 @@ const AvatarSection = ({ ) : ( <> {lnurl && setShowLnQr(true)} icon={{ name: "zap", size: 16 }} />} - {loginPubKey && !readonly && ( + {canWrite && ( navigate( @@ -80,6 +83,16 @@ const AvatarSection = ({ icon={{ name: "envelope", size: 16 }} /> )} + {!canWrite && !isMe && ( + { + if (confirm(intl.formatMessage({ defaultMessage: "View as user?", id: "LBAnc7" }))) { + LoginStore.loginWithPubkey(id, LoginSessionType.PublicKey); + } + }} + icon={{ name: "openeye", size: 16, className: "translate-y-0.5" }} + /> + )} )} diff --git a/packages/app/src/lang.json b/packages/app/src/lang.json index e149395e..8dcd0d65 100644 --- a/packages/app/src/lang.json +++ b/packages/app/src/lang.json @@ -688,6 +688,9 @@ "KtsyO0": { "defaultMessage": "Enter Pin" }, + "LBAnc7": { + "defaultMessage": "View as user?" + }, "LF5kYT": { "defaultMessage": "Other Connections" }, diff --git a/packages/app/src/translations/en.json b/packages/app/src/translations/en.json index 6e10b015..b08096dd 100644 --- a/packages/app/src/translations/en.json +++ b/packages/app/src/translations/en.json @@ -227,6 +227,7 @@ "KahimY": "Unknown event kind: {kind}", "KoFlZg": "Enter mint URL", "KtsyO0": "Enter Pin", + "LBAnc7": "View as user?", "LF5kYT": "Other Connections", "LR1XjT": "Pin too short", "LXxsbk": "Anonymous",