2024-01-26 02:41:31 +11:00
import { FormattedMessage } from 'react-intl' ;
2023-05-24 01:15:17 +10:00
2024-01-26 02:41:31 +11:00
import { Link } from 'react-router-dom' ;
2023-05-24 01:15:17 +10:00
2024-01-26 02:41:31 +11:00
import { useSelector } from 'react-redux' ;
2023-05-24 01:15:17 +10:00
2024-01-26 02:41:31 +11:00
import BarChart4BarsIcon from '@/material-icons/400-24px/bar_chart_4_bars.svg?react' ;
import PhotoLibraryIcon from '@/material-icons/400-24px/photo_library.svg?react' ;
import { Avatar } from 'mastodon/components/avatar' ;
import { DisplayName } from 'mastodon/components/display_name' ;
import { Icon } from 'mastodon/components/icon' ;
2024-07-19 00:36:09 +10:00
import { EmbeddedStatusContent } from 'mastodon/features/notifications_v2/components/embedded_status_content' ;
2016-11-19 01:36:16 +11:00
2024-01-26 02:41:31 +11:00
export const ReplyIndicator = ( ) => {
const inReplyToId = useSelector ( state => state . getIn ( [ 'compose' , 'in_reply_to' ] ) ) ;
const status = useSelector ( state => state . getIn ( [ 'statuses' , inReplyToId ] ) ) ;
const account = useSelector ( state => state . getIn ( [ 'accounts' , status ? . get ( 'account' ) ] ) ) ;
2023-05-24 01:15:17 +10:00
2024-01-26 02:41:31 +11:00
if ( ! status ) {
return null ;
}
2017-02-23 01:43:07 +11:00
2024-01-26 02:41:31 +11:00
return (
< div className = 'reply-indicator' >
< div className = 'reply-indicator__line' / >
2016-09-01 06:58:10 +10:00
2024-01-26 02:41:31 +11:00
< Link to = { ` /@ ${ account . get ( 'acct' ) } ` } className = 'detailed-status__display-avatar' >
< Avatar account = { account } size = { 46 } / >
< / Link >
2016-09-01 06:58:10 +10:00
2024-01-26 02:41:31 +11:00
< div className = 'reply-indicator__main' >
< Link to = { ` /@ ${ account . get ( 'acct' ) } ` } className = 'detailed-status__display-name' >
< DisplayName account = { account } / >
< / Link >
2016-09-01 06:58:10 +10:00
2024-07-19 00:36:09 +10:00
< EmbeddedStatusContent
className = 'reply-indicator__content translate'
content = { status . get ( 'contentHtml' ) }
language = { status . get ( 'language' ) }
mentions = { status . get ( 'mentions' ) }
/ >
2019-06-14 01:04:52 +10:00
2024-01-26 02:41:31 +11:00
{ ( status . get ( 'poll' ) || status . get ( 'media_attachments' ) . size > 0 ) && (
< div className = 'reply-indicator__attachments' >
{ status . get ( 'poll' ) && < > < Icon icon = { BarChart4BarsIcon } / > < FormattedMessage id = 'reply_indicator.poll' defaultMessage = 'Poll' / > < / > }
{ status . get ( 'media_attachments' ) . size > 0 && < > < Icon icon = { PhotoLibraryIcon } / > < FormattedMessage id = 'reply_indicator.attachments' defaultMessage = '{count, plural, one {# attachment} other {# attachments}}' values = { { count : status . get ( 'media_attachments' ) . size } } / > < / > }
< / div >
2019-06-14 01:04:52 +10:00
) }
2016-09-01 06:58:10 +10:00
< / div >
2024-01-26 02:41:31 +11:00
< / div >
) ;
} ;