Consolidate 'message user' in profile

This commit is contained in:
Chewbacca 2022-11-07 11:43:17 -05:00
parent 14353c1aff
commit 57b2629337
2 changed files with 33 additions and 19 deletions

View file

@ -317,13 +317,7 @@ const Header: React.FC<IHeader> = ({ account }) => {
icon: require('@tabler/icons/at.svg'), icon: require('@tabler/icons/at.svg'),
}); });
if (account.getIn(['pleroma', 'accepts_chat_messages']) === true) { if (features.privacyScopes) {
menu.push({
text: intl.formatMessage(messages.chat, { name: account.username }),
action: onChat,
icon: require('@tabler/icons/messages.svg'),
});
} else if (features.privacyScopes) {
menu.push({ menu.push({
text: intl.formatMessage(messages.direct, { name: account.username }), text: intl.formatMessage(messages.direct, { name: account.username }),
action: onDirect, action: onDirect,
@ -500,26 +494,41 @@ const Header: React.FC<IHeader> = ({ account }) => {
}; };
const renderMessageButton = () => { const renderMessageButton = () => {
if (!ownAccount || !account || account.id === ownAccount?.id) { if (features.chatsWithFollowers) { // Truth Social
return null; if (!ownAccount || !account || account.id === ownAccount?.id) {
return null;
}
const canChat = account.relationship?.followed_by;
if (!canChat) {
return null;
}
return (
<IconButton
src={require('@tabler/icons/mail.svg')}
onClick={() => createAndNavigateToChat.mutate(account.id)}
title={intl.formatMessage(messages.chat, { name: account.username })}
theme='outlined'
className='px-2'
iconClassName='w-4 h-4'
disabled={createAndNavigateToChat.isLoading}
/>
);
} }
const canChat = account.relationship?.followed_by; if (account.getIn(['pleroma', 'accepts_chat_messages']) === true) {
if (!canChat) {
return null;
}
return (
<IconButton <IconButton
src={require('@tabler/icons/mail.svg')} src={require('@tabler/icons/mail.svg')}
onClick={() => createAndNavigateToChat.mutate(account.id)} onClick={onChat}
title={intl.formatMessage(messages.chat, { name: account.username })} title={intl.formatMessage(messages.chat, { name: account.username })}
theme='outlined' theme='outlined'
className='px-2' className='px-2'
iconClassName='w-4 h-4' iconClassName='w-4 h-4'
disabled={createAndNavigateToChat.isLoading} />;
/> }
);
return null;
}; };
const renderShareButton = () => { const renderShareButton = () => {

View file

@ -234,6 +234,11 @@ const getInstanceFeatures = (instance: Instance) => {
*/ */
chatsV2: v.software === PLEROMA && gte(v.version, '2.3.0'), chatsV2: v.software === PLEROMA && gte(v.version, '2.3.0'),
/**
* Ability to only chat with people that follow you.
*/
chatsWithFollowers: v.software === TRUTHSOCIAL,
/** /**
* Mastodon's newer solution for direct messaging. * Mastodon's newer solution for direct messaging.
* @see {@link https://docs.joinmastodon.org/methods/timelines/conversations/} * @see {@link https://docs.joinmastodon.org/methods/timelines/conversations/}