feat: zap account directly

This commit is contained in:
P. Reis 2024-06-04 16:55:32 -03:00
parent 20ecc0586c
commit f1d6d32f92
1 changed files with 20 additions and 0 deletions

View File

@ -75,6 +75,7 @@ const messages = defineMessages({
profileExternal: { id: 'account.profile_external', defaultMessage: 'View profile on {domain}' }, profileExternal: { id: 'account.profile_external', defaultMessage: 'View profile on {domain}' },
header: { id: 'account.header.alt', defaultMessage: 'Profile header' }, header: { id: 'account.header.alt', defaultMessage: 'Profile header' },
subscribeFeed: { id: 'account.rss_feed', defaultMessage: 'Subscribe to RSS feed' }, subscribeFeed: { id: 'account.rss_feed', defaultMessage: 'Subscribe to RSS feed' },
zap: { id: 'zap.send_to', defaultMessage: 'Send zaps to {target}' },
}); });
interface IHeader { interface IHeader {
@ -282,6 +283,10 @@ const Header: React.FC<IHeader> = ({ account }) => {
copy(nip19.npubEncode(account.nostr.pubkey!)); copy(nip19.npubEncode(account.nostr.pubkey!));
}; };
const handleZapAccount: React.EventHandler<React.MouseEvent> = (e) => {
dispatch(openModal('ZAP_PAY_REQUEST', { account }));
};
const makeMenu = () => { const makeMenu = () => {
const menu: Menu = []; const menu: Menu = [];
@ -621,8 +626,22 @@ const Header: React.FC<IHeader> = ({ account }) => {
); );
}; };
const renderZapAccount = () => {
return (
<IconButton
src={require('@tabler/icons/outline/bolt.svg')}
onClick={handleZapAccount}
title={intl.formatMessage(messages.zap, { target: account.display_name })}
theme='outlined'
className='px-2'
iconClassName='h-4 w-4'
/>
);
};
const info = makeInfo(); const info = makeInfo();
const menu = makeMenu(); const menu = makeMenu();
const acceptsZaps = account.ditto.accepts_zaps === true;
return ( return (
<div className='-mx-4 -mt-4 sm:-mx-6 sm:-mt-6'> <div className='-mx-4 -mt-4 sm:-mx-6 sm:-mt-6'>
@ -664,6 +683,7 @@ const Header: React.FC<IHeader> = ({ account }) => {
<SubscriptionButton account={account} /> <SubscriptionButton account={account} />
{renderMessageButton()} {renderMessageButton()}
{renderShareButton()} {renderShareButton()}
{acceptsZaps && renderZapAccount()}
{menu.length > 0 && ( {menu.length > 0 && (
<DropdownMenu items={menu} placement='bottom-end'> <DropdownMenu items={menu} placement='bottom-end'>