|
|
|
@ -26,12 +26,18 @@ import StatusHeader from './status_header'; |
|
|
|
|
import StatusIcons from './status_icons'; |
|
|
|
|
import StatusPrepend from './status_prepend'; |
|
|
|
|
|
|
|
|
|
const domParser = new DOMParser(); |
|
|
|
|
|
|
|
|
|
export const textForScreenReader = (intl, status, rebloggedByText = false, expanded = false) => { |
|
|
|
|
const displayName = status.getIn(['account', 'display_name']); |
|
|
|
|
|
|
|
|
|
const spoilerText = status.getIn(['translation', 'spoiler_text']) || status.get('spoiler_text'); |
|
|
|
|
const contentHtml = status.getIn(['translation', 'contentHtml']) || status.get('contentHtml'); |
|
|
|
|
const contentText = domParser.parseFromString(contentHtml, 'text/html').documentElement.textContent; |
|
|
|
|
|
|
|
|
|
const values = [ |
|
|
|
|
displayName.length === 0 ? status.getIn(['account', 'acct']).split('@')[0] : displayName, |
|
|
|
|
status.get('spoiler_text') && !expanded ? status.get('spoiler_text') : status.get('search_index').slice(status.get('spoiler_text').length), |
|
|
|
|
spoilerText && !expanded ? spoilerText : contentText, |
|
|
|
|
intl.formatDate(status.get('created_at'), { hour: '2-digit', minute: '2-digit', month: 'short', day: 'numeric' }), |
|
|
|
|
status.getIn(['account', 'acct']), |
|
|
|
|
]; |
|
|
|
@ -391,12 +397,14 @@ class Status extends ImmutablePureComponent { |
|
|
|
|
|
|
|
|
|
handleOpenVideo = (options) => { |
|
|
|
|
const { status } = this.props; |
|
|
|
|
this.props.onOpenVideo(status.get('id'), status.getIn(['media_attachments', 0]), status.get('language'), options); |
|
|
|
|
const lang = status.getIn(['translation', 'language']) || status.get('language'); |
|
|
|
|
this.props.onOpenVideo(status.get('id'), status.getIn(['media_attachments', 0]), lang, options); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
handleOpenMedia = (media, index) => { |
|
|
|
|
const { status } = this.props; |
|
|
|
|
this.props.onOpenMedia(status.get('id'), media, index, status.get('language')); |
|
|
|
|
const lang = status.getIn(['translation', 'language']) || status.get('language'); |
|
|
|
|
this.props.onOpenMedia(status.get('id'), media, index, lang); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
handleHotkeyOpenMedia = e => { |
|
|
|
@ -406,10 +414,11 @@ class Status extends ImmutablePureComponent { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
|
|
if (status.get('media_attachments').size > 0) { |
|
|
|
|
const lang = status.getIn(['translation', 'language']) || status.get('language'); |
|
|
|
|
if (status.getIn(['media_attachments', 0, 'type']) === 'video') { |
|
|
|
|
onOpenVideo(statusId, status.getIn(['media_attachments', 0]), { startTime: 0 }); |
|
|
|
|
onOpenVideo(statusId, status.getIn(['media_attachments', 0]), lang, { startTime: 0 }); |
|
|
|
|
} else { |
|
|
|
|
onOpenMedia(statusId, status.get('media_attachments'), 0); |
|
|
|
|
onOpenMedia(statusId, status.get('media_attachments'), 0, lang); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -625,6 +634,8 @@ class Status extends ImmutablePureComponent { |
|
|
|
|
media.push(<PictureInPicturePlaceholder />); |
|
|
|
|
mediaIcons.push('video-camera'); |
|
|
|
|
} else if (attachments.size > 0) { |
|
|
|
|
const language = status.getIn(['translation', 'language']) || status.get('language'); |
|
|
|
|
|
|
|
|
|
if (muted || attachments.some(item => item.get('type') === 'unknown')) { |
|
|
|
|
media.push( |
|
|
|
|
<AttachmentList |
|
|
|
@ -634,14 +645,15 @@ class Status extends ImmutablePureComponent { |
|
|
|
|
); |
|
|
|
|
} else if (attachments.getIn([0, 'type']) === 'audio') { |
|
|
|
|
const attachment = status.getIn(['media_attachments', 0]); |
|
|
|
|
const description = attachment.getIn(['translation', 'description']) || attachment.get('description'); |
|
|
|
|
|
|
|
|
|
media.push( |
|
|
|
|
<Bundle fetchComponent={Audio} loading={this.renderLoadingAudioPlayer} > |
|
|
|
|
{Component => ( |
|
|
|
|
<Component |
|
|
|
|
src={attachment.get('url')} |
|
|
|
|
alt={attachment.get('description')} |
|
|
|
|
lang={status.get('language')} |
|
|
|
|
alt={description} |
|
|
|
|
lang={language} |
|
|
|
|
poster={attachment.get('preview_url') || status.getIn(['account', 'avatar_static'])} |
|
|
|
|
backgroundColor={attachment.getIn(['meta', 'colors', 'background'])} |
|
|
|
|
foregroundColor={attachment.getIn(['meta', 'colors', 'foreground'])} |
|
|
|
@ -662,6 +674,7 @@ class Status extends ImmutablePureComponent { |
|
|
|
|
mediaIcons.push('music'); |
|
|
|
|
} else if (attachments.getIn([0, 'type']) === 'video') { |
|
|
|
|
const attachment = status.getIn(['media_attachments', 0]); |
|
|
|
|
const description = attachment.getIn(['translation', 'description']) || attachment.get('description'); |
|
|
|
|
|
|
|
|
|
media.push( |
|
|
|
|
<Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} > |
|
|
|
@ -670,8 +683,8 @@ class Status extends ImmutablePureComponent { |
|
|
|
|
frameRate={attachment.getIn(['meta', 'original', 'frame_rate'])} |
|
|
|
|
blurhash={attachment.get('blurhash')} |
|
|
|
|
src={attachment.get('url')} |
|
|
|
|
alt={attachment.get('description')} |
|
|
|
|
lang={status.get('language')} |
|
|
|
|
alt={description} |
|
|
|
|
lang={language} |
|
|
|
|
inline |
|
|
|
|
sensitive={status.get('sensitive')} |
|
|
|
|
letterbox={settings.getIn(['media', 'letterbox'])} |
|
|
|
@ -691,7 +704,7 @@ class Status extends ImmutablePureComponent { |
|
|
|
|
{Component => ( |
|
|
|
|
<Component |
|
|
|
|
media={attachments} |
|
|
|
|
lang={status.get('language')} |
|
|
|
|
lang={language} |
|
|
|
|
sensitive={status.get('sensitive')} |
|
|
|
|
letterbox={settings.getIn(['media', 'letterbox'])} |
|
|
|
|
fullwidth={!rootId && settings.getIn(['media', 'fullwidth'])} |
|
|
|
@ -724,7 +737,8 @@ class Status extends ImmutablePureComponent { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (status.get('poll')) { |
|
|
|
|
contentMedia.push(<PollContainer pollId={status.get('poll')} lang={status.get('language')} />); |
|
|
|
|
const language = status.getIn(['translation', 'language']) || status.get('language'); |
|
|
|
|
contentMedia.push(<PollContainer pollId={status.get('poll')} lang={language} />); |
|
|
|
|
contentMediaIcons.push('tasks'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|