2017-04-22 04:05:35 +10:00
import PropTypes from 'prop-types' ;
2023-05-24 01:15:17 +10:00
2020-06-26 06:43:59 +10:00
import { injectIntl , defineMessages , FormattedMessage } from 'react-intl' ;
2023-05-24 01:15:17 +10:00
import classNames from 'classnames' ;
import ImmutablePropTypes from 'react-immutable-proptypes' ;
2017-05-03 10:04:16 +10:00
import ImmutablePureComponent from 'react-immutable-pure-component' ;
2023-05-24 01:15:17 +10:00
2017-10-06 10:07:59 +11:00
import { HotKeys } from 'react-hotkeys' ;
2023-05-24 01:15:17 +10:00
2024-01-16 21:27:26 +11:00
import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react' ;
import PushPinIcon from '@/material-icons/400-24px/push_pin.svg?react' ;
import RepeatIcon from '@/material-icons/400-24px/repeat.svg?react' ;
import ReplyIcon from '@/material-icons/400-24px/reply.svg?react' ;
2023-05-09 11:11:56 +10:00
import { Icon } from 'mastodon/components/icon' ;
2020-09-28 21:29:43 +10:00
import PictureInPicturePlaceholder from 'mastodon/components/picture_in_picture_placeholder' ;
2023-10-23 20:39:53 +11:00
import { withOptionalRouter , WithOptionalRouterPropTypes } from 'mastodon/utils/react_router' ;
2017-07-08 08:06:02 +10:00
2023-05-24 01:15:17 +10:00
import Card from '../features/status/components/card' ;
2017-07-08 08:06:02 +10:00
// We use the component (and not the container) since we do not want
// to use the progress bar to show download progress
import Bundle from '../features/ui/components/bundle' ;
2023-05-24 01:15:17 +10:00
import { MediaGallery , Video , Audio } from '../features/ui/util/async-components' ;
import { displayMedia } from '../initial_state' ;
import { Avatar } from './avatar' ;
import { AvatarOverlay } from './avatar_overlay' ;
import { DisplayName } from './display_name' ;
2023-08-22 03:39:01 +10:00
import { getHashtagBarForStatus } from './hashtag_bar' ;
2023-05-24 01:15:17 +10:00
import { RelativeTimestamp } from './relative_timestamp' ;
import StatusActionBar from './status_action_bar' ;
import StatusContent from './status_content' ;
2023-10-25 04:45:08 +11:00
import { VisibilityIcon } from './visibility_icon' ;
2016-08-25 01:56:44 +10:00
2023-06-01 08:10:21 +10:00
const domParser = new DOMParser ( ) ;
2018-08-27 01:53:26 +10:00
export const textForScreenReader = ( intl , status , rebloggedByText = false ) => {
2018-08-24 04:56:57 +10:00
const displayName = status . getIn ( [ 'account' , 'display_name' ] ) ;
2023-06-01 08:10:21 +10:00
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 ;
2018-08-24 04:56:57 +10:00
const values = [
displayName . length === 0 ? status . getIn ( [ 'account' , 'acct' ] ) . split ( '@' ) [ 0 ] : displayName ,
2023-06-01 08:10:21 +10:00
spoilerText && status . get ( 'hidden' ) ? spoilerText : contentText ,
2018-08-24 04:56:57 +10:00
intl . formatDate ( status . get ( 'created_at' ) , { hour : '2-digit' , minute : '2-digit' , month : 'short' , day : 'numeric' } ) ,
status . getIn ( [ 'account' , 'acct' ] ) ,
] ;
if ( rebloggedByText ) {
values . push ( rebloggedByText ) ;
}
return values . join ( ', ' ) ;
} ;
2019-05-26 21:48:16 +10:00
export const defaultMediaVisibility = ( status ) => {
if ( ! status ) {
return undefined ;
}
if ( status . get ( 'reblog' , null ) !== null && typeof status . get ( 'reblog' ) === 'object' ) {
status = status . get ( 'reblog' ) ;
}
return ( displayMedia !== 'hide_all' && ! status . get ( 'sensitive' ) || displayMedia === 'show_all' ) ;
} ;
2020-06-26 06:43:59 +10:00
const messages = defineMessages ( {
public _short : { id : 'privacy.public.short' , defaultMessage : 'Public' } ,
2024-01-26 02:41:31 +11:00
unlisted _short : { id : 'privacy.unlisted.short' , defaultMessage : 'Quiet public' } ,
private _short : { id : 'privacy.private.short' , defaultMessage : 'Followers' } ,
direct _short : { id : 'privacy.direct.short' , defaultMessage : 'Specific people' } ,
2022-01-20 08:37:27 +11:00
edited : { id : 'status.edited' , defaultMessage : 'Edited {date}' } ,
2020-06-26 06:43:59 +10:00
} ) ;
2018-09-15 01:59:48 +10:00
class Status extends ImmutablePureComponent {
2017-04-22 04:05:35 +10:00
2017-05-12 22:44:10 +10:00
static propTypes = {
status : ImmutablePropTypes . map ,
2023-11-04 02:00:03 +11:00
account : ImmutablePropTypes . record ,
2023-04-24 16:07:03 +10:00
previousId : PropTypes . string ,
nextInReplyToId : PropTypes . string ,
rootId : PropTypes . string ,
2018-10-20 11:23:58 +11:00
onClick : PropTypes . func ,
2017-05-12 22:44:10 +10:00
onReply : PropTypes . func ,
onFavourite : PropTypes . func ,
onReblog : PropTypes . func ,
onDelete : PropTypes . func ,
2018-04-10 01:09:11 +10:00
onDirect : PropTypes . func ,
onMention : PropTypes . func ,
2017-08-25 09:41:18 +10:00
onPin : PropTypes . func ,
2017-05-12 22:44:10 +10:00
onOpenMedia : PropTypes . func ,
onOpenVideo : PropTypes . func ,
onBlock : PropTypes . func ,
2022-08-25 12:27:47 +10:00
onAddFilter : PropTypes . func ,
2017-09-02 05:30:13 +10:00
onEmbed : PropTypes . func ,
2017-08-08 04:32:03 +10:00
onHeightChange : PropTypes . func ,
2018-03-11 19:52:59 +11:00
onToggleHidden : PropTypes . func ,
Summary: fix slowness due to layout thrashing when reloading a large … (#12661)
* Summary: fix slowness due to layout thrashing when reloading a large set of status updates
in order to limit the maximum size of a status in a list view (e.g. the home timeline), so as to avoid having to scroll all the way through an abnormally large status update (see https://github.com/tootsuite/mastodon/pull/8205), the following steps are taken:
•the element containing the status is rendered in the browser
•its height is calculated, to determine if it exceeds the maximum height threshold.
Unfortunately for performance, these steps are carried out in the componentDidMount(/Update) method, which also performs style modifications on the element. The combination of height request and style modification during javascript evaluation in the browser leads to layout-thrashing, where the elements are repeatedly re-laid-out (see https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing & https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Performance_best_practices_for_Firefox_fe_engineers).
The solution implemented here is to memoize the collapsed state in Redux the first time the status is seen (e.g. when fetched as part of a small batch, to populate the home timeline) , so that on subsequent re-renders, the value can be queried, rather than recalculated. This strategy is derived from https://github.com/tootsuite/mastodon/pull/4439 & https://github.com/tootsuite/mastodon/pull/4909, and should resolve https://github.com/tootsuite/mastodon/issues/12455.
Andrew Lin (https://github.com/onethreeseven) is thanked for his assistance in root cause analysis and solution brainstorming
* remove getSnapshotBeforeUpdate from status
* remove componentWillUnmount from status
* persist last-intersected status update and restore when ScrollableList is restored
e.g. when navigating from home-timeline to a status conversational thread and <Back again
* cache currently-viewing status id to avoid calling redux with identical value
* refactor collapse toggle to pass explicit boolean
2019-12-29 15:39:48 +11:00
onToggleCollapsed : PropTypes . func ,
2022-09-24 07:00:12 +10:00
onTranslate : PropTypes . func ,
2022-10-07 19:14:31 +11:00
onInteractionModal : PropTypes . func ,
2017-05-21 01:31:47 +10:00
muted : PropTypes . bool ,
2017-08-29 06:23:44 +10:00
hidden : PropTypes . bool ,
2018-10-20 11:23:58 +11:00
unread : PropTypes . bool ,
2017-10-06 10:07:59 +11:00
onMoveUp : PropTypes . func ,
onMoveDown : PropTypes . func ,
2018-11-09 07:08:57 +11:00
showThread : PropTypes . bool ,
2019-02-11 23:19:59 +11:00
getScrollPosition : PropTypes . func ,
updateScrollBottom : PropTypes . func ,
cacheMediaWidth : PropTypes . func ,
cachedMediaWidth : PropTypes . number ,
2020-07-09 23:09:19 +10:00
scrollKey : PropTypes . string ,
2020-09-28 21:29:43 +10:00
deployPictureInPicture : PropTypes . func ,
2020-12-08 05:36:36 +11:00
pictureInPicture : ImmutablePropTypes . contains ( {
2020-11-16 15:16:39 +11:00
inUse : PropTypes . bool ,
available : PropTypes . bool ,
} ) ,
2023-10-23 20:39:53 +11:00
... WithOptionalRouterPropTypes ,
2017-05-12 22:44:10 +10:00
} ;
2017-05-26 22:05:52 +10:00
// Avoid checking props that are functions (and whose equality will always
// evaluate to false. See react-immutable-pure-component for usage.
updateOnProps = [
'status' ,
'account' ,
'muted' ,
2017-08-29 06:23:44 +10:00
'hidden' ,
2020-09-27 04:57:07 +10:00
'unread' ,
2020-11-16 15:16:39 +11:00
'pictureInPicture' ,
2019-01-17 05:47:46 +11:00
] ;
2017-05-26 22:05:52 +10:00
2019-05-26 07:20:51 +10:00
state = {
2019-05-26 21:48:16 +10:00
showMedia : defaultMediaVisibility ( this . props . status ) ,
2019-05-30 00:33:15 +10:00
statusId : undefined ,
Revamp post filtering system (#18058)
* Add model for custom filter keywords
* Use CustomFilterKeyword internally
Does not change the API
* Fix /filters/edit and /filters/new
* Add migration tests
* Remove whole_word column from custom_filters (covered by custom_filter_keywords)
* Redesign /filters
Instead of a list, present a card that displays more information and handles
multiple keywords per filter.
* Redesign /filters/new and /filters/edit to add and remove keywords
This adds a new gem dependency: cocoon, as well as a npm dependency:
cocoon-js-vanilla. Those are used to easily populate and remove form fields
from the user interface when manipulating multiple keyword filters at once.
* Add /api/v2/filters to edit filter with multiple keywords
Entities:
- `Filter`: `id`, `title`, `filter_action` (either `hide` or `warn`), `context`
`keywords`
- `FilterKeyword`: `id`, `keyword`, `whole_word`
API endpoits:
- `GET /api/v2/filters` to list filters (including keywords)
- `POST /api/v2/filters` to create a new filter
`keywords_attributes` can also be passed to create keywords in one request
- `GET /api/v2/filters/:id` to read a particular filter
- `PUT /api/v2/filters/:id` to update a new filter
`keywords_attributes` can also be passed to edit, delete or add keywords in
one request
- `DELETE /api/v2/filters/:id` to delete a particular filter
- `GET /api/v2/filters/:id/keywords` to list keywords for a filter
- `POST /api/v2/filters/:filter_id/keywords/:id` to add a new keyword to a
filter
- `GET /api/v2/filter_keywords/:id` to read a particular keyword
- `PUT /api/v2/filter_keywords/:id` to edit a particular keyword
- `DELETE /api/v2/filter_keywords/:id` to delete a particular keyword
* Change from `irreversible` boolean to `action` enum
* Remove irrelevent `irreversible_must_be_within_context` check
* Fix /filters/new and /filters/edit with update for filter_action
* Fix Rubocop/Codeclimate complaining about task names
* Refactor FeedManager#phrase_filtered?
This moves regexp building and filter caching to the `CustomFilter` class.
This does not change the functional behavior yet, but this changes how the
cache is built, doing per-custom_filter regexps so that filters can be matched
independently, while still offering caching.
* Perform server-side filtering and output result in REST API
* Fix numerous filters_changed events being sent when editing multiple keywords at once
* Add some tests
* Use the new API in the WebUI
- use client-side logic for filters we have fetched rules for.
This is so that filter changes can be retroactively applied without
reloading the UI.
- use server-side logic for filters we haven't fetched rules for yet
(e.g. network error, or initial timeline loading)
* Minor optimizations and refactoring
* Perform server-side filtering on the streaming server
* Change the wording of filter action labels
* Fix issues pointed out by linter
* Change design of “Show anyway” link in accordence to review comments
* Drop “irreversible” filtering behavior
* Move /api/v2/filter_keywords to /api/v1/filters/keywords
* Rename `filter_results` attribute to `filtered`
* Rename REST::LegacyFilterSerializer to REST::V1::FilterSerializer
* Fix systemChannelId value in streaming server
* Simplify code by removing client-side filtering code
The simplifcation comes at a cost though: filters aren't retroactively
applied anymore.
2022-06-28 17:42:13 +10:00
forceFilter : undefined ,
2019-05-26 07:20:51 +10:00
} ;
2019-05-30 00:33:15 +10:00
static getDerivedStateFromProps ( nextProps , prevState ) {
if ( nextProps . status && nextProps . status . get ( 'id' ) !== prevState . statusId ) {
return {
showMedia : defaultMediaVisibility ( nextProps . status ) ,
statusId : nextProps . status . get ( 'id' ) ,
} ;
} else {
return null ;
2019-05-26 21:48:16 +10:00
}
}
2019-05-26 07:20:51 +10:00
handleToggleMediaVisibility = ( ) => {
this . setState ( { showMedia : ! this . state . showMedia } ) ;
2023-01-30 11:45:35 +11:00
} ;
2019-05-26 07:20:51 +10:00
2021-09-26 13:46:13 +10:00
handleClick = e => {
if ( e && ( e . button !== 0 || e . ctrlKey || e . metaKey ) ) {
2018-10-20 11:23:58 +11:00
return ;
}
2021-09-26 13:46:13 +10:00
if ( e ) {
e . preventDefault ( ) ;
2017-07-11 23:27:59 +10:00
}
2021-09-26 13:46:13 +10:00
this . handleHotkeyOpen ( ) ;
2023-01-30 11:45:35 +11:00
} ;
2016-09-16 08:21:51 +10:00
2021-11-27 08:04:09 +11:00
handlePrependAccountClick = e => {
this . handleAccountClick ( e , false ) ;
2023-01-30 11:45:35 +11:00
} ;
2021-11-27 08:04:09 +11:00
handleAccountClick = ( e , proper = true ) => {
2021-09-26 13:46:13 +10:00
if ( e && ( e . button !== 0 || e . ctrlKey || e . metaKey ) ) {
2019-06-11 03:27:10 +10:00
return ;
}
2021-09-26 13:46:13 +10:00
if ( e ) {
2016-09-16 08:21:51 +10:00
e . preventDefault ( ) ;
2023-02-20 18:11:23 +11:00
e . stopPropagation ( ) ;
2016-09-16 08:21:51 +10:00
}
2021-09-26 13:46:13 +10:00
2021-11-27 08:04:09 +11:00
this . _openProfile ( proper ) ;
2023-01-30 11:45:35 +11:00
} ;
2016-09-13 10:24:40 +10:00
2017-06-14 04:46:21 +10:00
handleExpandedToggle = ( ) => {
2018-03-11 19:52:59 +11:00
this . props . onToggleHidden ( this . _properStatus ( ) ) ;
2023-01-30 11:45:35 +11:00
} ;
Summary: fix slowness due to layout thrashing when reloading a large … (#12661)
* Summary: fix slowness due to layout thrashing when reloading a large set of status updates
in order to limit the maximum size of a status in a list view (e.g. the home timeline), so as to avoid having to scroll all the way through an abnormally large status update (see https://github.com/tootsuite/mastodon/pull/8205), the following steps are taken:
•the element containing the status is rendered in the browser
•its height is calculated, to determine if it exceeds the maximum height threshold.
Unfortunately for performance, these steps are carried out in the componentDidMount(/Update) method, which also performs style modifications on the element. The combination of height request and style modification during javascript evaluation in the browser leads to layout-thrashing, where the elements are repeatedly re-laid-out (see https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing & https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Performance_best_practices_for_Firefox_fe_engineers).
The solution implemented here is to memoize the collapsed state in Redux the first time the status is seen (e.g. when fetched as part of a small batch, to populate the home timeline) , so that on subsequent re-renders, the value can be queried, rather than recalculated. This strategy is derived from https://github.com/tootsuite/mastodon/pull/4439 & https://github.com/tootsuite/mastodon/pull/4909, and should resolve https://github.com/tootsuite/mastodon/issues/12455.
Andrew Lin (https://github.com/onethreeseven) is thanked for his assistance in root cause analysis and solution brainstorming
* remove getSnapshotBeforeUpdate from status
* remove componentWillUnmount from status
* persist last-intersected status update and restore when ScrollableList is restored
e.g. when navigating from home-timeline to a status conversational thread and <Back again
* cache currently-viewing status id to avoid calling redux with identical value
* refactor collapse toggle to pass explicit boolean
2019-12-29 15:39:48 +11:00
handleCollapsedToggle = isCollapsed => {
this . props . onToggleCollapsed ( this . _properStatus ( ) , isCollapsed ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-06-14 04:46:21 +10:00
2022-09-24 07:00:12 +10:00
handleTranslate = ( ) => {
this . props . onTranslate ( this . _properStatus ( ) ) ;
2023-01-30 11:45:35 +11:00
} ;
2022-09-24 07:00:12 +10:00
2023-07-24 21:46:55 +10:00
getAttachmentAspectRatio ( ) {
const attachments = this . _properStatus ( ) . get ( 'media_attachments' ) ;
2017-07-08 08:06:02 +10:00
2023-07-24 21:46:55 +10:00
if ( attachments . getIn ( [ 0 , 'type' ] ) === 'video' ) {
return ` ${ attachments . getIn ( [ 0 , 'meta' , 'original' , 'width' ] ) } / ${ attachments . getIn ( [ 0 , 'meta' , 'original' , 'height' ] ) } ` ;
} else if ( attachments . getIn ( [ 0 , 'type' ] ) === 'audio' ) {
return '16 / 9' ;
} else {
2023-10-09 22:38:29 +11:00
return ( attachments . size === 1 && attachments . getIn ( [ 0 , 'meta' , 'small' , 'aspect' ] ) ) ? attachments . getIn ( [ 0 , 'meta' , 'small' , 'aspect' ] ) : '3 / 2' ;
2023-07-24 21:46:55 +10:00
}
2019-08-24 06:38:02 +10:00
}
2023-07-24 21:46:55 +10:00
renderLoadingMediaGallery = ( ) => {
return (
< div className = 'media-gallery' style = { { aspectRatio : this . getAttachmentAspectRatio ( ) } } / >
) ;
} ;
renderLoadingVideoPlayer = ( ) => {
return (
< div className = 'video-player' style = { { aspectRatio : this . getAttachmentAspectRatio ( ) } } / >
) ;
} ;
renderLoadingAudioPlayer = ( ) => {
return (
< div className = 'audio-player' style = { { aspectRatio : this . getAttachmentAspectRatio ( ) } } / >
) ;
} ;
2017-07-08 08:06:02 +10:00
2020-12-07 14:29:37 +11:00
handleOpenVideo = ( options ) => {
const status = this . _properStatus ( ) ;
2023-06-01 08:10:21 +10:00
const lang = status . getIn ( [ 'translation' , 'language' ] ) || status . get ( 'language' ) ;
this . props . onOpenVideo ( status . get ( 'id' ) , status . getIn ( [ 'media_attachments' , 0 ] ) , lang , options ) ;
2023-01-30 11:45:35 +11:00
} ;
2020-11-27 13:24:11 +11:00
handleOpenMedia = ( media , index ) => {
2023-05-11 20:41:55 +10:00
const status = this . _properStatus ( ) ;
2023-06-01 08:10:21 +10:00
const lang = status . getIn ( [ 'translation' , 'language' ] ) || status . get ( 'language' ) ;
this . props . onOpenMedia ( status . get ( 'id' ) , media , index , lang ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-10-06 10:07:59 +11:00
2019-11-30 03:02:36 +11:00
handleHotkeyOpenMedia = e => {
2019-12-05 10:50:51 +11:00
const { onOpenMedia , onOpenVideo } = this . props ;
2020-12-09 10:24:13 +11:00
const status = this . _properStatus ( ) ;
2019-11-30 03:02:36 +11:00
e . preventDefault ( ) ;
if ( status . get ( 'media_attachments' ) . size > 0 ) {
2023-06-01 08:10:21 +10:00
const lang = status . getIn ( [ 'translation' , 'language' ] ) || status . get ( 'language' ) ;
2020-11-27 13:24:11 +11:00
if ( status . getIn ( [ 'media_attachments' , 0 , 'type' ] ) === 'video' ) {
2023-05-11 20:41:55 +10:00
onOpenVideo ( status . get ( 'id' ) , status . getIn ( [ 'media_attachments' , 0 ] ) , lang , { startTime : 0 } ) ;
2019-11-30 03:02:36 +11:00
} else {
2023-05-11 20:41:55 +10:00
onOpenMedia ( status . get ( 'id' ) , status . get ( 'media_attachments' ) , 0 , lang ) ;
2019-11-30 03:02:36 +11:00
}
}
2023-01-30 11:45:35 +11:00
} ;
2019-11-30 03:02:36 +11:00
2020-09-28 21:29:43 +10:00
handleDeployPictureInPicture = ( type , mediaProps ) => {
const { deployPictureInPicture } = this . props ;
const status = this . _properStatus ( ) ;
deployPictureInPicture ( status , type , mediaProps ) ;
2023-01-30 11:45:35 +11:00
} ;
2020-09-28 21:29:43 +10:00
2017-10-06 10:07:59 +11:00
handleHotkeyReply = e => {
e . preventDefault ( ) ;
2023-10-20 04:44:55 +11:00
this . props . onReply ( this . _properStatus ( ) , this . props . history ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-10-06 10:07:59 +11:00
handleHotkeyFavourite = ( ) => {
this . props . onFavourite ( this . _properStatus ( ) ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-10-06 10:07:59 +11:00
handleHotkeyBoost = e => {
this . props . onReblog ( this . _properStatus ( ) , e ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-10-06 10:07:59 +11:00
handleHotkeyMention = e => {
e . preventDefault ( ) ;
2023-10-20 04:44:55 +11:00
this . props . onMention ( this . _properStatus ( ) . get ( 'account' ) , this . props . history ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-10-06 10:07:59 +11:00
handleHotkeyOpen = ( ) => {
2021-09-26 13:46:13 +10:00
if ( this . props . onClick ) {
this . props . onClick ( ) ;
return ;
}
2023-10-20 04:44:55 +11:00
const { history } = this . props ;
2021-09-26 13:46:13 +10:00
const status = this . _properStatus ( ) ;
2023-10-20 04:44:55 +11:00
if ( ! history ) {
2021-09-26 13:46:13 +10:00
return ;
}
2023-10-20 04:44:55 +11:00
history . push ( ` /@ ${ status . getIn ( [ 'account' , 'acct' ] ) } / ${ status . get ( 'id' ) } ` ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-10-06 10:07:59 +11:00
handleHotkeyOpenProfile = ( ) => {
2021-11-27 08:04:09 +11:00
this . _openProfile ( ) ;
2023-01-30 11:45:35 +11:00
} ;
2021-11-27 08:04:09 +11:00
_openProfile = ( proper = true ) => {
2023-10-20 04:44:55 +11:00
const { history } = this . props ;
2021-11-27 08:04:09 +11:00
const status = proper ? this . _properStatus ( ) : this . props . status ;
2021-09-26 13:46:13 +10:00
2023-10-20 04:44:55 +11:00
if ( ! history ) {
2021-09-26 13:46:13 +10:00
return ;
}
2023-10-20 04:44:55 +11:00
history . push ( ` /@ ${ status . getIn ( [ 'account' , 'acct' ] ) } ` ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-10-06 10:07:59 +11:00
2018-04-21 02:14:21 +10:00
handleHotkeyMoveUp = e => {
this . props . onMoveUp ( this . props . status . get ( 'id' ) , e . target . getAttribute ( 'data-featured' ) ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-10-06 10:07:59 +11:00
2018-04-21 02:14:21 +10:00
handleHotkeyMoveDown = e => {
this . props . onMoveDown ( this . props . status . get ( 'id' ) , e . target . getAttribute ( 'data-featured' ) ) ;
2023-01-30 11:45:35 +11:00
} ;
2017-10-06 10:07:59 +11:00
2018-04-18 11:33:59 +10:00
handleHotkeyToggleHidden = ( ) => {
this . props . onToggleHidden ( this . _properStatus ( ) ) ;
2023-01-30 11:45:35 +11:00
} ;
2018-04-18 11:33:59 +10:00
2019-05-26 07:20:51 +10:00
handleHotkeyToggleSensitive = ( ) => {
this . handleToggleMediaVisibility ( ) ;
2023-01-30 11:45:35 +11:00
} ;
2019-05-26 07:20:51 +10:00
Revamp post filtering system (#18058)
* Add model for custom filter keywords
* Use CustomFilterKeyword internally
Does not change the API
* Fix /filters/edit and /filters/new
* Add migration tests
* Remove whole_word column from custom_filters (covered by custom_filter_keywords)
* Redesign /filters
Instead of a list, present a card that displays more information and handles
multiple keywords per filter.
* Redesign /filters/new and /filters/edit to add and remove keywords
This adds a new gem dependency: cocoon, as well as a npm dependency:
cocoon-js-vanilla. Those are used to easily populate and remove form fields
from the user interface when manipulating multiple keyword filters at once.
* Add /api/v2/filters to edit filter with multiple keywords
Entities:
- `Filter`: `id`, `title`, `filter_action` (either `hide` or `warn`), `context`
`keywords`
- `FilterKeyword`: `id`, `keyword`, `whole_word`
API endpoits:
- `GET /api/v2/filters` to list filters (including keywords)
- `POST /api/v2/filters` to create a new filter
`keywords_attributes` can also be passed to create keywords in one request
- `GET /api/v2/filters/:id` to read a particular filter
- `PUT /api/v2/filters/:id` to update a new filter
`keywords_attributes` can also be passed to edit, delete or add keywords in
one request
- `DELETE /api/v2/filters/:id` to delete a particular filter
- `GET /api/v2/filters/:id/keywords` to list keywords for a filter
- `POST /api/v2/filters/:filter_id/keywords/:id` to add a new keyword to a
filter
- `GET /api/v2/filter_keywords/:id` to read a particular keyword
- `PUT /api/v2/filter_keywords/:id` to edit a particular keyword
- `DELETE /api/v2/filter_keywords/:id` to delete a particular keyword
* Change from `irreversible` boolean to `action` enum
* Remove irrelevent `irreversible_must_be_within_context` check
* Fix /filters/new and /filters/edit with update for filter_action
* Fix Rubocop/Codeclimate complaining about task names
* Refactor FeedManager#phrase_filtered?
This moves regexp building and filter caching to the `CustomFilter` class.
This does not change the functional behavior yet, but this changes how the
cache is built, doing per-custom_filter regexps so that filters can be matched
independently, while still offering caching.
* Perform server-side filtering and output result in REST API
* Fix numerous filters_changed events being sent when editing multiple keywords at once
* Add some tests
* Use the new API in the WebUI
- use client-side logic for filters we have fetched rules for.
This is so that filter changes can be retroactively applied without
reloading the UI.
- use server-side logic for filters we haven't fetched rules for yet
(e.g. network error, or initial timeline loading)
* Minor optimizations and refactoring
* Perform server-side filtering on the streaming server
* Change the wording of filter action labels
* Fix issues pointed out by linter
* Change design of “Show anyway” link in accordence to review comments
* Drop “irreversible” filtering behavior
* Move /api/v2/filter_keywords to /api/v1/filters/keywords
* Rename `filter_results` attribute to `filtered`
* Rename REST::LegacyFilterSerializer to REST::V1::FilterSerializer
* Fix systemChannelId value in streaming server
* Simplify code by removing client-side filtering code
The simplifcation comes at a cost though: filters aren't retroactively
applied anymore.
2022-06-28 17:42:13 +10:00
handleUnfilterClick = e => {
this . setState ( { forceFilter : false } ) ;
e . preventDefault ( ) ;
2023-01-30 11:45:35 +11:00
} ;
Revamp post filtering system (#18058)
* Add model for custom filter keywords
* Use CustomFilterKeyword internally
Does not change the API
* Fix /filters/edit and /filters/new
* Add migration tests
* Remove whole_word column from custom_filters (covered by custom_filter_keywords)
* Redesign /filters
Instead of a list, present a card that displays more information and handles
multiple keywords per filter.
* Redesign /filters/new and /filters/edit to add and remove keywords
This adds a new gem dependency: cocoon, as well as a npm dependency:
cocoon-js-vanilla. Those are used to easily populate and remove form fields
from the user interface when manipulating multiple keyword filters at once.
* Add /api/v2/filters to edit filter with multiple keywords
Entities:
- `Filter`: `id`, `title`, `filter_action` (either `hide` or `warn`), `context`
`keywords`
- `FilterKeyword`: `id`, `keyword`, `whole_word`
API endpoits:
- `GET /api/v2/filters` to list filters (including keywords)
- `POST /api/v2/filters` to create a new filter
`keywords_attributes` can also be passed to create keywords in one request
- `GET /api/v2/filters/:id` to read a particular filter
- `PUT /api/v2/filters/:id` to update a new filter
`keywords_attributes` can also be passed to edit, delete or add keywords in
one request
- `DELETE /api/v2/filters/:id` to delete a particular filter
- `GET /api/v2/filters/:id/keywords` to list keywords for a filter
- `POST /api/v2/filters/:filter_id/keywords/:id` to add a new keyword to a
filter
- `GET /api/v2/filter_keywords/:id` to read a particular keyword
- `PUT /api/v2/filter_keywords/:id` to edit a particular keyword
- `DELETE /api/v2/filter_keywords/:id` to delete a particular keyword
* Change from `irreversible` boolean to `action` enum
* Remove irrelevent `irreversible_must_be_within_context` check
* Fix /filters/new and /filters/edit with update for filter_action
* Fix Rubocop/Codeclimate complaining about task names
* Refactor FeedManager#phrase_filtered?
This moves regexp building and filter caching to the `CustomFilter` class.
This does not change the functional behavior yet, but this changes how the
cache is built, doing per-custom_filter regexps so that filters can be matched
independently, while still offering caching.
* Perform server-side filtering and output result in REST API
* Fix numerous filters_changed events being sent when editing multiple keywords at once
* Add some tests
* Use the new API in the WebUI
- use client-side logic for filters we have fetched rules for.
This is so that filter changes can be retroactively applied without
reloading the UI.
- use server-side logic for filters we haven't fetched rules for yet
(e.g. network error, or initial timeline loading)
* Minor optimizations and refactoring
* Perform server-side filtering on the streaming server
* Change the wording of filter action labels
* Fix issues pointed out by linter
* Change design of “Show anyway” link in accordence to review comments
* Drop “irreversible” filtering behavior
* Move /api/v2/filter_keywords to /api/v1/filters/keywords
* Rename `filter_results` attribute to `filtered`
* Rename REST::LegacyFilterSerializer to REST::V1::FilterSerializer
* Fix systemChannelId value in streaming server
* Simplify code by removing client-side filtering code
The simplifcation comes at a cost though: filters aren't retroactively
applied anymore.
2022-06-28 17:42:13 +10:00
handleFilterClick = ( ) => {
this . setState ( { forceFilter : true } ) ;
2023-01-30 11:45:35 +11:00
} ;
Revamp post filtering system (#18058)
* Add model for custom filter keywords
* Use CustomFilterKeyword internally
Does not change the API
* Fix /filters/edit and /filters/new
* Add migration tests
* Remove whole_word column from custom_filters (covered by custom_filter_keywords)
* Redesign /filters
Instead of a list, present a card that displays more information and handles
multiple keywords per filter.
* Redesign /filters/new and /filters/edit to add and remove keywords
This adds a new gem dependency: cocoon, as well as a npm dependency:
cocoon-js-vanilla. Those are used to easily populate and remove form fields
from the user interface when manipulating multiple keyword filters at once.
* Add /api/v2/filters to edit filter with multiple keywords
Entities:
- `Filter`: `id`, `title`, `filter_action` (either `hide` or `warn`), `context`
`keywords`
- `FilterKeyword`: `id`, `keyword`, `whole_word`
API endpoits:
- `GET /api/v2/filters` to list filters (including keywords)
- `POST /api/v2/filters` to create a new filter
`keywords_attributes` can also be passed to create keywords in one request
- `GET /api/v2/filters/:id` to read a particular filter
- `PUT /api/v2/filters/:id` to update a new filter
`keywords_attributes` can also be passed to edit, delete or add keywords in
one request
- `DELETE /api/v2/filters/:id` to delete a particular filter
- `GET /api/v2/filters/:id/keywords` to list keywords for a filter
- `POST /api/v2/filters/:filter_id/keywords/:id` to add a new keyword to a
filter
- `GET /api/v2/filter_keywords/:id` to read a particular keyword
- `PUT /api/v2/filter_keywords/:id` to edit a particular keyword
- `DELETE /api/v2/filter_keywords/:id` to delete a particular keyword
* Change from `irreversible` boolean to `action` enum
* Remove irrelevent `irreversible_must_be_within_context` check
* Fix /filters/new and /filters/edit with update for filter_action
* Fix Rubocop/Codeclimate complaining about task names
* Refactor FeedManager#phrase_filtered?
This moves regexp building and filter caching to the `CustomFilter` class.
This does not change the functional behavior yet, but this changes how the
cache is built, doing per-custom_filter regexps so that filters can be matched
independently, while still offering caching.
* Perform server-side filtering and output result in REST API
* Fix numerous filters_changed events being sent when editing multiple keywords at once
* Add some tests
* Use the new API in the WebUI
- use client-side logic for filters we have fetched rules for.
This is so that filter changes can be retroactively applied without
reloading the UI.
- use server-side logic for filters we haven't fetched rules for yet
(e.g. network error, or initial timeline loading)
* Minor optimizations and refactoring
* Perform server-side filtering on the streaming server
* Change the wording of filter action labels
* Fix issues pointed out by linter
* Change design of “Show anyway” link in accordence to review comments
* Drop “irreversible” filtering behavior
* Move /api/v2/filter_keywords to /api/v1/filters/keywords
* Rename `filter_results` attribute to `filtered`
* Rename REST::LegacyFilterSerializer to REST::V1::FilterSerializer
* Fix systemChannelId value in streaming server
* Simplify code by removing client-side filtering code
The simplifcation comes at a cost though: filters aren't retroactively
applied anymore.
2022-06-28 17:42:13 +10:00
2017-10-06 10:07:59 +11:00
_properStatus ( ) {
const { status } = this . props ;
if ( status . get ( 'reblog' , null ) !== null && typeof status . get ( 'reblog' ) === 'object' ) {
return status . get ( 'reblog' ) ;
} else {
return status ;
}
2017-09-14 11:39:10 +10:00
}
2019-02-11 23:19:59 +11:00
handleRef = c => {
this . node = c ;
2023-01-30 11:45:35 +11:00
} ;
2019-02-11 23:19:59 +11:00
2016-08-25 05:08:00 +10:00
render ( ) {
2023-04-24 16:07:03 +10:00
const { intl , hidden , featured , unread , showThread , scrollKey , pictureInPicture , previousId , nextInReplyToId , rootId } = this . props ;
2016-09-06 04:38:31 +10:00
2017-10-06 10:07:59 +11:00
let { status , account , ... other } = this . props ;
2016-10-25 20:13:16 +11:00
if ( status === null ) {
2017-05-26 22:07:48 +10:00
return null ;
2017-05-25 01:55:00 +10:00
}
2019-08-20 03:00:33 +10:00
const handlers = this . props . muted ? { } : {
reply : this . handleHotkeyReply ,
favourite : this . handleHotkeyFavourite ,
boost : this . handleHotkeyBoost ,
mention : this . handleHotkeyMention ,
open : this . handleHotkeyOpen ,
openProfile : this . handleHotkeyOpenProfile ,
moveUp : this . handleHotkeyMoveUp ,
moveDown : this . handleHotkeyMoveDown ,
toggleHidden : this . handleHotkeyToggleHidden ,
toggleSensitive : this . handleHotkeyToggleSensitive ,
2019-11-30 03:02:36 +11:00
openMedia : this . handleHotkeyOpenMedia ,
2019-08-20 03:00:33 +10:00
} ;
2023-04-24 16:07:03 +10:00
let media , statusAvatar , prepend , rebloggedByText ;
2017-08-29 06:23:44 +10:00
if ( hidden ) {
2017-05-25 01:55:00 +10:00
return (
2019-08-20 03:00:33 +10:00
< HotKeys handlers = { handlers } >
2023-04-05 00:33:44 +10:00
< div ref = { this . handleRef } className = { classNames ( 'status__wrapper' , { focusable : ! this . props . muted } ) } tabIndex = { 0 } >
2021-07-23 10:53:17 +10:00
< span > { status . getIn ( [ 'account' , 'display_name' ] ) || status . getIn ( [ 'account' , 'username' ] ) } < / span >
< span > { status . get ( 'content' ) } < / span >
2019-08-20 03:00:33 +10:00
< / div >
< / HotKeys >
2017-05-25 01:55:00 +10:00
) ;
2016-10-25 20:13:16 +11:00
}
2023-04-24 16:07:03 +10:00
const connectUp = previousId && previousId === status . get ( 'in_reply_to_id' ) ;
const connectToRoot = rootId && rootId === status . get ( 'in_reply_to_id' ) ;
const connectReply = nextInReplyToId && nextInReplyToId === status . get ( 'id' ) ;
2022-06-30 17:51:55 +10:00
const matchedFilters = status . get ( 'matched_filters' ) ;
2023-04-24 16:07:03 +10:00
Revamp post filtering system (#18058)
* Add model for custom filter keywords
* Use CustomFilterKeyword internally
Does not change the API
* Fix /filters/edit and /filters/new
* Add migration tests
* Remove whole_word column from custom_filters (covered by custom_filter_keywords)
* Redesign /filters
Instead of a list, present a card that displays more information and handles
multiple keywords per filter.
* Redesign /filters/new and /filters/edit to add and remove keywords
This adds a new gem dependency: cocoon, as well as a npm dependency:
cocoon-js-vanilla. Those are used to easily populate and remove form fields
from the user interface when manipulating multiple keyword filters at once.
* Add /api/v2/filters to edit filter with multiple keywords
Entities:
- `Filter`: `id`, `title`, `filter_action` (either `hide` or `warn`), `context`
`keywords`
- `FilterKeyword`: `id`, `keyword`, `whole_word`
API endpoits:
- `GET /api/v2/filters` to list filters (including keywords)
- `POST /api/v2/filters` to create a new filter
`keywords_attributes` can also be passed to create keywords in one request
- `GET /api/v2/filters/:id` to read a particular filter
- `PUT /api/v2/filters/:id` to update a new filter
`keywords_attributes` can also be passed to edit, delete or add keywords in
one request
- `DELETE /api/v2/filters/:id` to delete a particular filter
- `GET /api/v2/filters/:id/keywords` to list keywords for a filter
- `POST /api/v2/filters/:filter_id/keywords/:id` to add a new keyword to a
filter
- `GET /api/v2/filter_keywords/:id` to read a particular keyword
- `PUT /api/v2/filter_keywords/:id` to edit a particular keyword
- `DELETE /api/v2/filter_keywords/:id` to delete a particular keyword
* Change from `irreversible` boolean to `action` enum
* Remove irrelevent `irreversible_must_be_within_context` check
* Fix /filters/new and /filters/edit with update for filter_action
* Fix Rubocop/Codeclimate complaining about task names
* Refactor FeedManager#phrase_filtered?
This moves regexp building and filter caching to the `CustomFilter` class.
This does not change the functional behavior yet, but this changes how the
cache is built, doing per-custom_filter regexps so that filters can be matched
independently, while still offering caching.
* Perform server-side filtering and output result in REST API
* Fix numerous filters_changed events being sent when editing multiple keywords at once
* Add some tests
* Use the new API in the WebUI
- use client-side logic for filters we have fetched rules for.
This is so that filter changes can be retroactively applied without
reloading the UI.
- use server-side logic for filters we haven't fetched rules for yet
(e.g. network error, or initial timeline loading)
* Minor optimizations and refactoring
* Perform server-side filtering on the streaming server
* Change the wording of filter action labels
* Fix issues pointed out by linter
* Change design of “Show anyway” link in accordence to review comments
* Drop “irreversible” filtering behavior
* Move /api/v2/filter_keywords to /api/v1/filters/keywords
* Rename `filter_results` attribute to `filtered`
* Rename REST::LegacyFilterSerializer to REST::V1::FilterSerializer
* Fix systemChannelId value in streaming server
* Simplify code by removing client-side filtering code
The simplifcation comes at a cost though: filters aren't retroactively
applied anymore.
2022-06-28 17:42:13 +10:00
if ( this . state . forceFilter === undefined ? matchedFilters : this . state . forceFilter ) {
2018-06-29 23:34:36 +10:00
const minHandlers = this . props . muted ? { } : {
moveUp : this . handleHotkeyMoveUp ,
moveDown : this . handleHotkeyMoveDown ,
} ;
return (
< HotKeys handlers = { minHandlers } >
2023-04-05 00:33:44 +10:00
< div className = 'status__wrapper status__wrapper--filtered focusable' tabIndex = { 0 } ref = { this . handleRef } >
Revamp post filtering system (#18058)
* Add model for custom filter keywords
* Use CustomFilterKeyword internally
Does not change the API
* Fix /filters/edit and /filters/new
* Add migration tests
* Remove whole_word column from custom_filters (covered by custom_filter_keywords)
* Redesign /filters
Instead of a list, present a card that displays more information and handles
multiple keywords per filter.
* Redesign /filters/new and /filters/edit to add and remove keywords
This adds a new gem dependency: cocoon, as well as a npm dependency:
cocoon-js-vanilla. Those are used to easily populate and remove form fields
from the user interface when manipulating multiple keyword filters at once.
* Add /api/v2/filters to edit filter with multiple keywords
Entities:
- `Filter`: `id`, `title`, `filter_action` (either `hide` or `warn`), `context`
`keywords`
- `FilterKeyword`: `id`, `keyword`, `whole_word`
API endpoits:
- `GET /api/v2/filters` to list filters (including keywords)
- `POST /api/v2/filters` to create a new filter
`keywords_attributes` can also be passed to create keywords in one request
- `GET /api/v2/filters/:id` to read a particular filter
- `PUT /api/v2/filters/:id` to update a new filter
`keywords_attributes` can also be passed to edit, delete or add keywords in
one request
- `DELETE /api/v2/filters/:id` to delete a particular filter
- `GET /api/v2/filters/:id/keywords` to list keywords for a filter
- `POST /api/v2/filters/:filter_id/keywords/:id` to add a new keyword to a
filter
- `GET /api/v2/filter_keywords/:id` to read a particular keyword
- `PUT /api/v2/filter_keywords/:id` to edit a particular keyword
- `DELETE /api/v2/filter_keywords/:id` to delete a particular keyword
* Change from `irreversible` boolean to `action` enum
* Remove irrelevent `irreversible_must_be_within_context` check
* Fix /filters/new and /filters/edit with update for filter_action
* Fix Rubocop/Codeclimate complaining about task names
* Refactor FeedManager#phrase_filtered?
This moves regexp building and filter caching to the `CustomFilter` class.
This does not change the functional behavior yet, but this changes how the
cache is built, doing per-custom_filter regexps so that filters can be matched
independently, while still offering caching.
* Perform server-side filtering and output result in REST API
* Fix numerous filters_changed events being sent when editing multiple keywords at once
* Add some tests
* Use the new API in the WebUI
- use client-side logic for filters we have fetched rules for.
This is so that filter changes can be retroactively applied without
reloading the UI.
- use server-side logic for filters we haven't fetched rules for yet
(e.g. network error, or initial timeline loading)
* Minor optimizations and refactoring
* Perform server-side filtering on the streaming server
* Change the wording of filter action labels
* Fix issues pointed out by linter
* Change design of “Show anyway” link in accordence to review comments
* Drop “irreversible” filtering behavior
* Move /api/v2/filter_keywords to /api/v1/filters/keywords
* Rename `filter_results` attribute to `filtered`
* Rename REST::LegacyFilterSerializer to REST::V1::FilterSerializer
* Fix systemChannelId value in streaming server
* Simplify code by removing client-side filtering code
The simplifcation comes at a cost though: filters aren't retroactively
applied anymore.
2022-06-28 17:42:13 +10:00
< FormattedMessage id = 'status.filtered' defaultMessage = 'Filtered' / > : { matchedFilters . join ( ', ' ) } .
{ ' ' }
< button className = 'status__wrapper--filtered__button' onClick = { this . handleUnfilterClick } >
< FormattedMessage id = 'status.show_filter_reason' defaultMessage = 'Show anyway' / >
< / button >
2018-06-29 23:34:36 +10:00
< / div >
< / HotKeys >
) ;
}
2018-03-04 19:19:11 +11:00
if ( featured ) {
prepend = (
< div className = 'status__prepend' >
2023-10-25 04:45:08 +11:00
< div className = 'status__prepend-icon-wrapper' > < Icon id = 'thumb-tack' icon = { PushPinIcon } className = 'status__prepend-icon' / > < / div >
2022-04-29 08:24:31 +10:00
< FormattedMessage id = 'status.pinned' defaultMessage = 'Pinned post' / >
2018-03-04 19:19:11 +11:00
< / div >
) ;
} else if ( status . get ( 'reblog' , null ) !== null && typeof status . get ( 'reblog' ) === 'object' ) {
2017-08-08 04:32:03 +10:00
const display _name _html = { _ _html : status . getIn ( [ 'account' , 'display_name_html' ] ) } ;
2016-11-19 10:28:42 +11:00
2017-10-06 10:07:59 +11:00
prepend = (
< div className = 'status__prepend' >
2023-10-25 04:45:08 +11:00
< div className = 'status__prepend-icon-wrapper' > < Icon id = 'retweet' icon = { RepeatIcon } className = 'status__prepend-icon' / > < / div >
2022-11-14 07:10:20 +11:00
< FormattedMessage id = 'status.reblogged_by' defaultMessage = '{name} boosted' values = { { name : < a onClick = { this . handlePrependAccountClick } data - id = { status . getIn ( [ 'account' , 'id' ] ) } href = { ` /@ ${ status . getIn ( [ 'account' , 'acct' ] ) } ` } className = 'status__display-name muted' > < bdi > < strong dangerouslySetInnerHTML = { display _name _html } / > < / bdi > < / a > } } / >
2017-08-29 06:23:44 +10:00
< / div >
2016-09-01 22:12:11 +10:00
) ;
2017-10-06 10:07:59 +11:00
2018-08-24 04:56:57 +10:00
rebloggedByText = intl . formatMessage ( { id : 'status.reblogged_by' , defaultMessage : '{name} boosted' } , { name : status . getIn ( [ 'account' , 'acct' ] ) } ) ;
2017-10-06 10:07:59 +11:00
account = status . get ( 'account' ) ;
status = status . get ( 'reblog' ) ;
2023-03-31 00:16:20 +11:00
} else if ( status . get ( 'visibility' ) === 'direct' ) {
prepend = (
< div className = 'status__prepend' >
2023-10-25 04:45:08 +11:00
< div className = 'status__prepend-icon-wrapper' > < Icon id = 'at' icon = { AlternateEmailIcon } className = 'status__prepend-icon' / > < / div >
2023-03-31 00:16:20 +11:00
< FormattedMessage id = 'status.direct_indicator' defaultMessage = 'Private mention' / >
< / div >
) ;
2022-10-26 04:02:21 +11:00
} else if ( showThread && status . get ( 'in_reply_to_id' ) && status . get ( 'in_reply_to_account_id' ) === status . getIn ( [ 'account' , 'id' ] ) ) {
const display _name _html = { _ _html : status . getIn ( [ 'account' , 'display_name_html' ] ) } ;
prepend = (
< div className = 'status__prepend' >
2023-10-25 04:45:08 +11:00
< div className = 'status__prepend-icon-wrapper' > < Icon id = 'reply' icon = { ReplyIcon } className = 'status__prepend-icon' / > < / div >
2022-11-14 07:10:20 +11:00
< FormattedMessage id = 'status.replied_to' defaultMessage = 'Replied to {name}' values = { { name : < a onClick = { this . handlePrependAccountClick } data - id = { status . getIn ( [ 'account' , 'id' ] ) } href = { ` /@ ${ status . getIn ( [ 'account' , 'acct' ] ) } ` } className = 'status__display-name muted' > < bdi > < strong dangerouslySetInnerHTML = { display _name _html } / > < / bdi > < / a > } } / >
2022-10-26 04:02:21 +11:00
< / div >
) ;
2016-09-01 22:12:11 +10:00
}
2016-08-25 01:56:44 +10:00
2020-12-08 05:36:36 +11:00
if ( pictureInPicture . get ( 'inUse' ) ) {
2023-07-24 21:46:55 +10:00
media = < PictureInPicturePlaceholder aspectRatio = { this . getAttachmentAspectRatio ( ) } / > ;
2020-09-28 21:29:43 +10:00
} else if ( status . get ( 'media_attachments' ) . size > 0 ) {
2023-06-01 08:10:21 +10:00
const language = status . getIn ( [ 'translation' , 'language' ] ) || status . get ( 'language' ) ;
2023-07-24 21:46:55 +10:00
if ( status . getIn ( [ 'media_attachments' , 0 , 'type' ] ) === 'audio' ) {
2019-08-24 06:38:02 +10:00
const attachment = status . getIn ( [ 'media_attachments' , 0 ] ) ;
2023-06-01 08:10:21 +10:00
const description = attachment . getIn ( [ 'translation' , 'description' ] ) || attachment . get ( 'description' ) ;
2019-08-24 06:38:02 +10:00
media = (
< Bundle fetchComponent = { Audio } loading = { this . renderLoadingAudioPlayer } >
{ Component => (
< Component
src = { attachment . get ( 'url' ) }
2023-06-01 08:10:21 +10:00
alt = { description }
lang = { language }
2020-06-29 21:56:55 +10:00
poster = { attachment . get ( 'preview_url' ) || status . getIn ( [ 'account' , 'avatar_static' ] ) }
2020-07-06 02:28:25 +10:00
backgroundColor = { attachment . getIn ( [ 'meta' , 'colors' , 'background' ] ) }
foregroundColor = { attachment . getIn ( [ 'meta' , 'colors' , 'foreground' ] ) }
accentColor = { attachment . getIn ( [ 'meta' , 'colors' , 'accent' ] ) }
2019-08-24 06:38:02 +10:00
duration = { attachment . getIn ( [ 'meta' , 'original' , 'duration' ] , 0 ) }
2020-06-21 10:27:19 +10:00
width = { this . props . cachedMediaWidth }
2020-06-23 20:20:14 +10:00
height = { 110 }
2020-06-21 10:27:19 +10:00
cacheWidth = { this . props . cacheMediaWidth }
2020-12-08 05:36:36 +11:00
deployPictureInPicture = { pictureInPicture . get ( 'available' ) ? this . handleDeployPictureInPicture : undefined }
2022-08-13 23:39:05 +10:00
sensitive = { status . get ( 'sensitive' ) }
blurhash = { attachment . get ( 'blurhash' ) }
visible = { this . state . showMedia }
onToggleVisibility = { this . handleToggleMediaVisibility }
2019-08-24 06:38:02 +10:00
/ >
) }
< / Bundle >
) ;
} else if ( status . getIn ( [ 'media_attachments' , 0 , 'type' ] ) === 'video' ) {
2019-06-20 07:42:38 +10:00
const attachment = status . getIn ( [ 'media_attachments' , 0 ] ) ;
2023-06-01 08:10:21 +10:00
const description = attachment . getIn ( [ 'translation' , 'description' ] ) || attachment . get ( 'description' ) ;
2017-09-14 11:39:10 +10:00
2017-07-08 08:06:02 +10:00
media = (
2017-09-14 11:39:10 +10:00
< Bundle fetchComponent = { Video } loading = { this . renderLoadingVideoPlayer } >
2018-01-18 02:57:15 +11:00
{ Component => (
< Component
2019-06-20 07:42:38 +10:00
preview = { attachment . get ( 'preview_url' ) }
2020-11-22 09:19:04 +11:00
frameRate = { attachment . getIn ( [ 'meta' , 'original' , 'frame_rate' ] ) }
2023-07-24 21:46:55 +10:00
aspectRatio = { ` ${ attachment . getIn ( [ 'meta' , 'original' , 'width' ] ) } / ${ attachment . getIn ( [ 'meta' , 'original' , 'height' ] ) } ` }
2019-06-20 07:42:38 +10:00
blurhash = { attachment . get ( 'blurhash' ) }
src = { attachment . get ( 'url' ) }
2023-06-01 08:10:21 +10:00
alt = { description }
lang = { language }
2018-01-18 02:57:15 +11:00
sensitive = { status . get ( 'sensitive' ) }
onOpenVideo = { this . handleOpenVideo }
2020-12-08 05:36:36 +11:00
deployPictureInPicture = { pictureInPicture . get ( 'available' ) ? this . handleDeployPictureInPicture : undefined }
2019-05-26 07:20:51 +10:00
visible = { this . state . showMedia }
onToggleVisibility = { this . handleToggleMediaVisibility }
2018-01-18 02:57:15 +11:00
/ >
) }
2017-07-08 08:06:02 +10:00
< / Bundle >
) ;
2016-09-18 02:05:02 +10:00
} else {
2017-07-08 08:06:02 +10:00
media = (
2018-05-08 21:33:09 +10:00
< Bundle fetchComponent = { MediaGallery } loading = { this . renderLoadingMediaGallery } >
2019-02-11 23:19:59 +11:00
{ Component => (
< Component
media = { status . get ( 'media_attachments' ) }
2023-06-01 08:10:21 +10:00
lang = { language }
2019-02-11 23:19:59 +11:00
sensitive = { status . get ( 'sensitive' ) }
height = { 110 }
2020-11-27 13:24:11 +11:00
onOpenMedia = { this . handleOpenMedia }
2019-02-11 23:19:59 +11:00
cacheWidth = { this . props . cacheMediaWidth }
defaultWidth = { this . props . cachedMediaWidth }
2019-05-26 07:20:51 +10:00
visible = { this . state . showMedia }
onToggleVisibility = { this . handleToggleMediaVisibility }
2019-02-11 23:19:59 +11:00
/ >
) }
2017-07-08 08:06:02 +10:00
< / Bundle >
) ;
2016-09-18 02:05:02 +10:00
}
2023-07-24 21:46:55 +10:00
} else if ( status . get ( 'spoiler_text' ) . length === 0 && status . get ( 'card' ) ) {
2018-10-28 16:35:03 +11:00
media = (
< Card
2020-12-08 22:07:54 +11:00
onOpenMedia = { this . handleOpenMedia }
2018-10-28 16:35:03 +11:00
card = { status . get ( 'card' ) }
compact
2020-06-07 01:41:56 +10:00
sensitive = { status . get ( 'sensitive' ) }
2018-10-28 16:35:03 +11:00
/ >
) ;
2016-09-06 04:38:31 +10:00
}
2022-05-31 01:10:13 +10:00
if ( account === undefined || account === null ) {
2022-10-26 04:02:21 +11:00
statusAvatar = < Avatar account = { status . get ( 'account' ) } size = { 46 } / > ;
2018-10-20 11:23:58 +11:00
} else {
2017-08-08 03:44:55 +10:00
statusAvatar = < AvatarOverlay account = { status . get ( 'account' ) } friend = { account } / > ;
2017-05-03 19:43:37 +10:00
}
2023-08-22 03:39:01 +10:00
const { statusContentProps , hashtagBar } = getHashtagBarForStatus ( status ) ;
2023-09-19 20:25:39 +10:00
const expanded = ! status . get ( 'hidden' ) || status . get ( 'spoiler_text' ) . length === 0 ;
2023-08-22 03:39:01 +10:00
2016-08-25 01:56:44 +10:00
return (
2017-10-06 10:07:59 +11:00
< HotKeys handlers = { handlers } >
2023-08-25 19:31:20 +10:00
< div className = { classNames ( 'status__wrapper' , ` status__wrapper- ${ status . get ( 'visibility' ) } ` , { 'status__wrapper-reply' : ! ! status . get ( 'in_reply_to_id' ) , unread , focusable : ! this . props . muted } ) } tabIndex = { this . props . muted ? null : 0 } data - featured = { featured ? 'true' : null } aria - label = { textForScreenReader ( intl , status , rebloggedByText ) } ref = { this . handleRef } data - nosnippet = { status . getIn ( [ 'account' , 'noindex' ] , true ) || undefined } >
2017-10-06 10:07:59 +11:00
{ prepend }
2016-08-25 05:08:00 +10:00
2023-04-24 16:07:03 +10:00
< div className = { classNames ( 'status' , ` status- ${ status . get ( 'visibility' ) } ` , { 'status-reply' : ! ! status . get ( 'in_reply_to_id' ) , 'status--in-thread' : ! ! rootId , 'status--first-in-thread' : previousId && ( ! connectUp || connectToRoot ) , muted : this . props . muted } ) } data - id = { status . get ( 'id' ) } >
{ ( connectReply || connectUp || connectToRoot ) && < div className = { classNames ( 'status__line' , { 'status__line--full' : connectReply , 'status__line--first' : ! status . get ( 'in_reply_to_id' ) && ! connectToRoot } ) } / > }
2023-04-24 06:24:53 +10:00
{ /* eslint-disable-next-line jsx-a11y/no-static-element-interactions */ }
2023-02-20 18:11:23 +11:00
< div onClick = { this . handleClick } className = 'status__info' >
< a href = { ` /@ ${ status . getIn ( [ 'account' , 'acct' ] ) } / ${ status . get ( 'id' ) } ` } className = 'status__relative-time' target = '_blank' rel = 'noopener noreferrer' >
2023-10-25 04:45:08 +11:00
< span className = 'status__visibility-icon' > < VisibilityIcon visibility = { status . get ( 'visibility' ) } / > < / span >
2024-02-29 20:40:13 +11:00
< RelativeTimestamp timestamp = { status . get ( 'created_at' ) } / > { status . get ( 'edited_at' ) && < abbr title = { intl . formatMessage ( messages . edited , { date : intl . formatDate ( status . get ( 'edited_at' ) , { year : 'numeric' , month : 'short' , day : '2-digit' , hour : '2-digit' , minute : '2-digit' } ) } ) } > * < / abbr > }
2020-10-27 13:00:47 +11:00
< / a >
2016-08-25 05:08:00 +10:00
2022-11-14 07:10:20 +11:00
< a onClick = { this . handleAccountClick } href = { ` /@ ${ status . getIn ( [ 'account' , 'acct' ] ) } ` } title = { status . getIn ( [ 'account' , 'acct' ] ) } className = 'status__display-name' target = '_blank' rel = 'noopener noreferrer' >
2017-10-06 10:07:59 +11:00
< div className = 'status__avatar' >
{ statusAvatar }
< / div >
2016-09-01 06:58:10 +10:00
2022-05-31 01:10:13 +10:00
< DisplayName account = { status . get ( 'account' ) } / >
2017-10-06 10:07:59 +11:00
< / a >
< / div >
2022-09-24 07:00:12 +10:00
< StatusContent
status = { status }
onClick = { this . handleClick }
2023-08-23 23:40:31 +10:00
expanded = { expanded }
2022-09-24 07:00:12 +10:00
onExpandedToggle = { this . handleExpandedToggle }
onTranslate = { this . handleTranslate }
2023-04-14 19:01:23 +10:00
collapsible
2022-09-24 07:00:12 +10:00
onCollapsedToggle = { this . handleCollapsedToggle }
2023-08-22 03:39:01 +10:00
{ ... statusContentProps }
2022-09-24 07:00:12 +10:00
/ >
2016-08-25 05:08:00 +10:00
2017-10-06 10:07:59 +11:00
{ media }
2016-09-06 04:38:31 +10:00
2023-08-23 23:40:31 +10:00
{ expanded && hashtagBar }
2023-08-15 07:42:30 +10:00
2022-08-25 12:37:40 +10:00
< StatusActionBar scrollKey = { scrollKey } status = { status } account = { account } onFilter = { matchedFilters ? this . handleFilterClick : null } { ...other } / >
2017-10-06 10:07:59 +11:00
< / div >
< / div >
< / HotKeys >
2016-08-25 01:56:44 +10:00
) ;
}
2016-09-01 00:15:12 +10:00
2017-04-22 04:05:35 +10:00
}
2023-03-24 13:17:53 +11:00
2023-10-20 04:44:55 +11:00
export default withOptionalRouter ( injectIntl ( Status ) ) ;