"view as user" button in profile
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
import { LNURL } from "@snort/shared";
|
import { LNURL } from "@snort/shared";
|
||||||
import { CachedMetadata, encodeTLVEntries, NostrPrefix, TLVEntryType } from "@snort/system";
|
import { CachedMetadata, encodeTLVEntries, NostrPrefix, TLVEntryType } from "@snort/system";
|
||||||
import React, { useMemo, useState } from "react";
|
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 { Link, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import IconButton from "@/Components/Button/IconButton";
|
import IconButton from "@/Components/Button/IconButton";
|
||||||
@ -14,6 +14,7 @@ import FollowButton from "@/Components/User/FollowButton";
|
|||||||
import ProfileImage from "@/Components/User/ProfileImage";
|
import ProfileImage from "@/Components/User/ProfileImage";
|
||||||
import ZapModal from "@/Components/ZapModal/ZapModal";
|
import ZapModal from "@/Components/ZapModal/ZapModal";
|
||||||
import { hexToBech32 } from "@/Utils";
|
import { hexToBech32 } from "@/Utils";
|
||||||
|
import { LoginSessionType, LoginStore } from "@/Utils/Login";
|
||||||
|
|
||||||
const AvatarSection = ({
|
const AvatarSection = ({
|
||||||
user,
|
user,
|
||||||
@ -34,6 +35,8 @@ const AvatarSection = ({
|
|||||||
const profileId = useMemo(() => hexToBech32(CONFIG.profileLinkPrefix, id), [id]);
|
const profileId = useMemo(() => hexToBech32(CONFIG.profileLinkPrefix, id), [id]);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const isMe = loginPubKey === id;
|
const isMe = loginPubKey === id;
|
||||||
|
const canWrite = !!loginPubKey && !readonly;
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
const renderButtons = () => {
|
const renderButtons = () => {
|
||||||
if (!id) return null;
|
if (!id) return null;
|
||||||
@ -66,7 +69,7 @@ const AvatarSection = ({
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{lnurl && <IconButton onClick={() => setShowLnQr(true)} icon={{ name: "zap", size: 16 }} />}
|
{lnurl && <IconButton onClick={() => setShowLnQr(true)} icon={{ name: "zap", size: 16 }} />}
|
||||||
{loginPubKey && !readonly && (
|
{canWrite && (
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate(
|
navigate(
|
||||||
@ -80,6 +83,16 @@ const AvatarSection = ({
|
|||||||
icon={{ name: "envelope", size: 16 }}
|
icon={{ name: "envelope", size: 16 }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{!canWrite && !isMe && (
|
||||||
|
<IconButton
|
||||||
|
onClick={() => {
|
||||||
|
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" }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -688,6 +688,9 @@
|
|||||||
"KtsyO0": {
|
"KtsyO0": {
|
||||||
"defaultMessage": "Enter Pin"
|
"defaultMessage": "Enter Pin"
|
||||||
},
|
},
|
||||||
|
"LBAnc7": {
|
||||||
|
"defaultMessage": "View as user?"
|
||||||
|
},
|
||||||
"LF5kYT": {
|
"LF5kYT": {
|
||||||
"defaultMessage": "Other Connections"
|
"defaultMessage": "Other Connections"
|
||||||
},
|
},
|
||||||
|
@ -227,6 +227,7 @@
|
|||||||
"KahimY": "Unknown event kind: {kind}",
|
"KahimY": "Unknown event kind: {kind}",
|
||||||
"KoFlZg": "Enter mint URL",
|
"KoFlZg": "Enter mint URL",
|
||||||
"KtsyO0": "Enter Pin",
|
"KtsyO0": "Enter Pin",
|
||||||
|
"LBAnc7": "View as user?",
|
||||||
"LF5kYT": "Other Connections",
|
"LF5kYT": "Other Connections",
|
||||||
"LR1XjT": "Pin too short",
|
"LR1XjT": "Pin too short",
|
||||||
"LXxsbk": "Anonymous",
|
"LXxsbk": "Anonymous",
|
||||||
|
Reference in New Issue
Block a user