copy npub
This commit is contained in:
parent
d43e0bf068
commit
283e865006
|
@ -1,6 +1,7 @@
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
import { List as ImmutableList } from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
|
import { npubEncode } from 'nostr-tools/nip19';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
@ -45,6 +46,7 @@ const messages = defineMessages({
|
||||||
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
|
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
|
||||||
report: { id: 'account.report', defaultMessage: 'Report @{name}' },
|
report: { id: 'account.report', defaultMessage: 'Report @{name}' },
|
||||||
copy: { id: 'account.copy', defaultMessage: 'Copy link to profile' },
|
copy: { id: 'account.copy', defaultMessage: 'Copy link to profile' },
|
||||||
|
npub: { id: 'account.npub', defaultMessage: 'Copy user Npub' },
|
||||||
share: { id: 'account.share', defaultMessage: 'Share @{name}\'s profile' },
|
share: { id: 'account.share', defaultMessage: 'Share @{name}\'s profile' },
|
||||||
media: { id: 'account.media', defaultMessage: 'Media' },
|
media: { id: 'account.media', defaultMessage: 'Media' },
|
||||||
blockDomain: { id: 'account.block_domain', defaultMessage: 'Hide everything from {domain}' },
|
blockDomain: { id: 'account.block_domain', defaultMessage: 'Hide everything from {domain}' },
|
||||||
|
@ -276,6 +278,16 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
copy(account.url);
|
copy(account.url);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCopyNpub: React.EventHandler<React.MouseEvent> = (e) => {
|
||||||
|
// Check if the account object has an 'pubkey' property, convert to npub, and copy it
|
||||||
|
if (account && account.nostr.pubkey) {
|
||||||
|
const npub = npubEncode(account.nostr.pubkey);
|
||||||
|
copy(npub);
|
||||||
|
} else {
|
||||||
|
console.error('Account Npub is not available.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const makeMenu = () => {
|
const makeMenu = () => {
|
||||||
const menu: Menu = [];
|
const menu: Menu = [];
|
||||||
|
|
||||||
|
@ -316,6 +328,12 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
icon: require('@tabler/icons/outline/clipboard-copy.svg'),
|
icon: require('@tabler/icons/outline/clipboard-copy.svg'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
menu.push({
|
||||||
|
text: intl.formatMessage(messages.npub),
|
||||||
|
action: handleCopyNpub,
|
||||||
|
icon: require('@tabler/icons/outline/clipboard-copy.svg'),
|
||||||
|
});
|
||||||
|
|
||||||
if (!ownAccount) return menu;
|
if (!ownAccount) return menu;
|
||||||
|
|
||||||
if (features.searchFromAccount) {
|
if (features.searchFromAccount) {
|
||||||
|
|
Loading…
Reference in New Issue