"view as user" button in profile
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Martti Malmi 2024-01-20 13:00:30 +02:00
parent 6a1a990e57
commit 6354472d05
3 changed files with 19 additions and 2 deletions

View File

@ -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 && <IconButton onClick={() => setShowLnQr(true)} icon={{ name: "zap", size: 16 }} />}
{loginPubKey && !readonly && (
{canWrite && (
<IconButton
onClick={() =>
navigate(
@ -80,6 +83,16 @@ const AvatarSection = ({
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" }}
/>
)}
</>
)}
</>

View File

@ -688,6 +688,9 @@
"KtsyO0": {
"defaultMessage": "Enter Pin"
},
"LBAnc7": {
"defaultMessage": "View as user?"
},
"LF5kYT": {
"defaultMessage": "Other Connections"
},

View File

@ -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",