Merge branch 'copy-npub' into 'main'
Copy npub See merge request soapbox-pub/soapbox!3022
This commit is contained in:
commit
8bb3128ab6
|
@ -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 { nip19 } from 'nostr-tools';
|
||||||
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,10 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
copy(account.url);
|
copy(account.url);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCopyNpub: React.EventHandler<React.MouseEvent> = (e) => {
|
||||||
|
copy(nip19.npubEncode(account.nostr.pubkey!));
|
||||||
|
};
|
||||||
|
|
||||||
const makeMenu = () => {
|
const makeMenu = () => {
|
||||||
const menu: Menu = [];
|
const menu: Menu = [];
|
||||||
|
|
||||||
|
@ -316,6 +322,14 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
icon: require('@tabler/icons/outline/clipboard-copy.svg'),
|
icon: require('@tabler/icons/outline/clipboard-copy.svg'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (account.nostr.pubkey) {
|
||||||
|
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) {
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
"account.mute": "Mute @{name}",
|
"account.mute": "Mute @{name}",
|
||||||
"account.muted": "Muted",
|
"account.muted": "Muted",
|
||||||
"account.never_active": "Never",
|
"account.never_active": "Never",
|
||||||
|
"account.npub": "Copy user npub",
|
||||||
"account.patron": "Patron",
|
"account.patron": "Patron",
|
||||||
"account.posts": "Posts",
|
"account.posts": "Posts",
|
||||||
"account.posts_with_replies": "Posts & replies",
|
"account.posts_with_replies": "Posts & replies",
|
||||||
|
|
Loading…
Reference in New Issue