@@ -41,7 +41,7 @@ import { openModal } from '../../actions/modal';
4141import { defineMessages , injectIntl , FormattedMessage } from 'react-intl' ;
4242import ImmutablePureComponent from 'react-immutable-pure-component' ;
4343import { HotKeys } from 'react-hotkeys' ;
44- import { boostModal , deleteModal } from '../../initial_state' ;
44+ import { boostModal , deleteModal , displayMedia } from '../../initial_state' ;
4545import { attachFullscreenListener , detachFullscreenListener , isFullscreen } from '../ui/util/fullscreen' ;
4646import { textForScreenReader } from '../../components/status' ;
4747import Icon from 'mastodon/components/icon' ;
@@ -131,6 +131,7 @@ class Status extends ImmutablePureComponent {
131131
132132 state = {
133133 fullscreen : false ,
134+ showMedia : ! this . props . status ? undefined : ( displayMedia !== 'hide_all' && ! this . props . status . get ( 'sensitive' ) || displayMedia === 'show_all' ) ,
134135 } ;
135136
136137 componentWillMount ( ) {
@@ -146,6 +147,13 @@ class Status extends ImmutablePureComponent {
146147 this . _scrolledIntoView = false ;
147148 this . props . dispatch ( fetchStatus ( nextProps . params . statusId ) ) ;
148149 }
150+ if ( ! Immutable . is ( nextProps . status , this . props . status ) && nextProps . status ) {
151+ this . setState ( { showMedia : displayMedia !== 'hide_all' && ! nextProps . status . get ( 'sensitive' ) || displayMedia === 'show_all' } ) ;
152+ }
153+ }
154+
155+ handleToggleMediaVisibility = ( ) => {
156+ this . setState ( { showMedia : ! this . state . showMedia } ) ;
149157 }
150158
151159 handleFavouriteClick = ( status ) => {
@@ -312,6 +320,10 @@ class Status extends ImmutablePureComponent {
312320 this . handleToggleHidden ( this . props . status ) ;
313321 }
314322
323+ handleHotkeyToggleSensitive = ( ) => {
324+ this . handleToggleMediaVisibility ( ) ;
325+ }
326+
315327 handleMoveUp = id => {
316328 const { status, ancestorsIds, descendantsIds } = this . props ;
317329
@@ -432,6 +444,7 @@ class Status extends ImmutablePureComponent {
432444 mention : this . handleHotkeyMention ,
433445 openProfile : this . handleHotkeyOpenProfile ,
434446 toggleHidden : this . handleHotkeyToggleHidden ,
447+ toggleSensitive : this . handleHotkeyToggleSensitive ,
435448 } ;
436449
437450 return (
@@ -455,6 +468,8 @@ class Status extends ImmutablePureComponent {
455468 onOpenMedia = { this . handleOpenMedia }
456469 onToggleHidden = { this . handleToggleHidden }
457470 domain = { domain }
471+ showMedia = { this . state . showMedia }
472+ onToggleMediaVisibility = { this . handleToggleMediaVisibility }
458473 />
459474
460475 < ActionBar
0 commit comments