1
0

[Glitch] Fix status title for statuses without text

Port f05fb51ecb to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Ivan Rodriguez 2023-04-14 10:29:09 -05:00 committed by Claire
parent f2797276b2
commit a21a875dba

View File

@ -63,6 +63,7 @@ const messages = defineMessages({
redraftMessage: { id: 'confirmations.redraft.message', defaultMessage: 'Are you sure you want to delete this status and re-draft it? You will lose all replies, boosts and favourites to it.' }, redraftMessage: { id: 'confirmations.redraft.message', defaultMessage: 'Are you sure you want to delete this status and re-draft it? You will lose all replies, boosts and favourites to it.' },
revealAll: { id: 'status.show_more_all', defaultMessage: 'Show more for all' }, revealAll: { id: 'status.show_more_all', defaultMessage: 'Show more for all' },
hideAll: { id: 'status.show_less_all', defaultMessage: 'Show less for all' }, hideAll: { id: 'status.show_less_all', defaultMessage: 'Show less for all' },
statusTitleWithAttachments: { id: 'status.title.with_attachments', defaultMessage: '{user} posted {attachmentCount, plural, one {an attachment} other {{attachmentCount} attachments}}' },
detailedStatus: { id: 'status.detailed_status', defaultMessage: 'Detailed conversation view' }, detailedStatus: { id: 'status.detailed_status', defaultMessage: 'Detailed conversation view' },
replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' }, replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' },
replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' }, replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
@ -161,13 +162,14 @@ const truncate = (str, num) => {
} }
}; };
const titleFromStatus = status => { const titleFromStatus = (intl, status) => {
const displayName = status.getIn(['account', 'display_name']); const displayName = status.getIn(['account', 'display_name']);
const username = status.getIn(['account', 'username']); const username = status.getIn(['account', 'username']);
const prefix = displayName.trim().length === 0 ? username : displayName; const user = displayName.trim().length === 0 ? username : displayName;
const text = status.get('search_index'); const text = status.get('search_index');
const attachmentCount = status.get('media_attachments').size;
return `${prefix}: "${truncate(text, 30)}"`; return text ? `${user}: "${truncate(text, 30)}"` : intl.formatMessage(messages.statusTitleWithAttachments, { user, attachmentCount });
}; };
class Status extends ImmutablePureComponent { class Status extends ImmutablePureComponent {
@ -710,7 +712,7 @@ class Status extends ImmutablePureComponent {
</ScrollContainer> </ScrollContainer>
<Helmet> <Helmet>
<title>{titleFromStatus(status)}</title> <title>{titleFromStatus(intl, status)}</title>
<meta name='robots' content={(isLocal && isIndexable) ? 'all' : 'noindex'} /> <meta name='robots' content={(isLocal && isIndexable) ? 'all' : 'noindex'} />
</Helmet> </Helmet>
</Column> </Column>