]> cat aescling's git repositories - mastodon.git/commitdiff
add local setting to auto reveal media behind cw
authorash lea <ashlea@protonmail.com>
Sun, 10 Mar 2019 19:34:51 +0000 (15:34 -0400)
committerThibG <thib@sitedethib.com>
Mon, 11 Mar 2019 11:14:45 +0000 (12:14 +0100)
app/javascript/flavours/glitch/components/media_gallery.js
app/javascript/flavours/glitch/components/status.js
app/javascript/flavours/glitch/features/local_settings/page/index.js
app/javascript/flavours/glitch/features/status/components/detailed_status.js
app/javascript/flavours/glitch/features/video/index.js
app/javascript/flavours/glitch/reducers/local_settings.js

index 1fa25ee4eca855795bc1a88e56b93167a308f62f..28af21812d03c547e6f076194d54c3753dbdb60e 100644 (file)
@@ -238,7 +238,8 @@ export default class MediaGallery extends React.PureComponent {
   };
 
   componentWillReceiveProps (nextProps) {
-    if (!is(nextProps.media, this.props.media)) {
+    console.log(nextProps.revealed);
+    if (!is(nextProps.media, this.props.media) || nextProps.revealed === true) {
       this.setState({ visible: nextProps.revealed === undefined ? (displayMedia !== 'hide_all' && !nextProps.sensitive || displayMedia === 'show_all') : nextProps.revealed });
     }
   }
index 31f4f1ddd32863c19fa4cf716065385afec77cea..c8bf75f790f2dcbe36128512eaafdb47d340cfd6 100644 (file)
@@ -466,6 +466,7 @@ export default class Status extends ImmutablePureComponent {
               onOpenVideo={this.handleOpenVideo}
               width={this.props.cachedMediaWidth}
               cacheWidth={this.props.cacheMediaWidth}
+              revealed={settings.getIn(['media', 'reveal_behind_cw']) && !!status.get('spoiler_text') ? true : undefined}
             />)}
           </Bundle>
         );
@@ -483,6 +484,7 @@ export default class Status extends ImmutablePureComponent {
                 onOpenMedia={this.props.onOpenMedia}
                 cacheWidth={this.props.cacheMediaWidth}
                 defaultWidth={this.props.cachedMediaWidth}
+                revealed={settings.getIn(['media', 'reveal_behind_cw']) && !!status.get('spoiler_text') ? true : undefined}
               />
             )}
           </Bundle>
index 4535d9849f0b013343230d3c2e3af2912ce7e37e..bc4ad359ce0e0af40c3d0612f3b4e11d6c45d561 100644 (file)
@@ -328,6 +328,14 @@ export default class LocalSettingsPage extends React.PureComponent {
         >
           <FormattedMessage id='settings.inline_preview_cards' defaultMessage='Inline preview cards for external links' />
         </LocalSettingsPageItem>
+        <LocalSettingsPageItem
+          settings={settings}
+          item={['media', 'reveal_behind_cw']}
+          id='mastodon-settings--reveal-behind-cw'
+          onChange={onChange}
+        >
+          <FormattedMessage id='settings.media_reveal_behind_cw' defaultMessage='Reveal sensitive media behind a CW by default' />
+        </LocalSettingsPageItem>
       </div>
     ),
   ];
index ad60320efe86380d401a44eacb6783d4a9f844c5..373532e20ecb0e27d2ff89d30146dc34cc28c847 100644 (file)
@@ -138,6 +138,7 @@ export default class DetailedStatus extends ImmutablePureComponent {
             preventPlayback={!expanded}
             onOpenVideo={this.handleOpenVideo}
             autoplay
+            revealed={settings.getIn(['media', 'reveal_behind_cw']) && !!status.get('spoiler_text') ? true : undefined}
           />
         );
         mediaIcon = 'video-camera';
@@ -151,6 +152,7 @@ export default class DetailedStatus extends ImmutablePureComponent {
             fullwidth={settings.getIn(['media', 'fullwidth'])}
             hidden={!expanded}
             onOpenMedia={this.props.onOpenMedia}
+            revealed={settings.getIn(['media', 'reveal_behind_cw']) && !!status.get('spoiler_text') ? true : undefined}
           />
         );
         mediaIcon = 'picture-o';
index cf66536c4115ad040a41311be1b703e670ae2264..e3ed799c7ed4203d66492d9318773667628c9932 100644 (file)
@@ -119,6 +119,12 @@ export default class Video extends React.PureComponent {
     revealed: this.props.revealed === undefined ? (displayMedia !== 'hide_all' && !this.props.sensitive || displayMedia === 'show_all') : this.props.revealed,
   };
 
+  componentWillReceiveProps (nextProps) {
+    if (nextProps.revealed === true) {
+      this.setState({ revealed: true });
+    }
+  }
+
   // hard coded in components.scss
   // any way to get ::before values programatically?
   volWidth = 50;
index 93a4043285e26a46987df63fd5c8ac40afe6e7e8..ef694d4ead8853426589515736d477c5fffef8db 100644 (file)
@@ -39,8 +39,9 @@ const initialState = ImmutableMap({
     show_action_bar : true,
   }),
   media     : ImmutableMap({
-    letterbox   : true,
-    fullwidth   : true,
+    letterbox        : true,
+    fullwidth        : true,
+    reveal_behind_cw : false,
   }),
   notifications : ImmutableMap({
     favicon_badge : false,