From 3f4e27ab6f33ab1a18954a3046e6e9abdc2d5e12 Mon Sep 17 00:00:00 2001 From: Claire Date: Sun, 24 Jul 2022 11:10:49 +0200 Subject: Add local setting toggle to move media attachments outside CWs Fixes #1812 --- .../flavours/glitch/components/status.js | 30 +++++++++++++++++----- .../glitch/features/local_settings/page/index.js | 9 +++++++ .../features/status/components/detailed_status.js | 27 ++++++++++++++----- .../flavours/glitch/reducers/local_settings.js | 3 ++- 4 files changed, 55 insertions(+), 14 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index 8a5fda676..d3bdcdc91 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -508,8 +508,21 @@ class Status extends ImmutablePureComponent { const { isExpanded, isCollapsed, forceFilter } = this.state; let background = null; let attachments = null; - let media = []; - let mediaIcons = []; + + // Depending on user settings, some media are considered as parts of the + // contents (affected by CW) while other will be displayed outside of the + // CW. + let contentMedia = []; + let contentMediaIcons = []; + let extraMedia = []; + let extraMediaIcons = []; + let media = contentMedia; + let mediaIcons = contentMediaIcons; + + if (settings.getIn(['content_warnings', 'media_outside'])) { + media = extraMedia; + mediaIcons = extraMediaIcons; + } if (status === null) { return null; @@ -681,8 +694,8 @@ class Status extends ImmutablePureComponent { } if (status.get('poll')) { - media.push(); - mediaIcons.push('tasks'); + contentMedia.push(); + contentMediaIcons.push('tasks'); } // Here we prepare extra data-* attributes for CSS selectors. @@ -748,7 +761,7 @@ class Status extends ImmutablePureComponent { + + {extraMedia} + {!isCollapsed || !(muted || !settings.getIn(['collapsed', 'show_action_bar'])) ? ( (

+ + + + ); - mediaIcons.push('tasks'); + contentMedia.push(); + contentMediaIcons.push('tasks'); } if (status.get('application')) { @@ -282,8 +295,8 @@ class DetailedStatus extends ImmutablePureComponent { + {extraMedia} +
diff --git a/app/javascript/flavours/glitch/reducers/local_settings.js b/app/javascript/flavours/glitch/reducers/local_settings.js index d4cdc124f..6d8feaf66 100644 --- a/app/javascript/flavours/glitch/reducers/local_settings.js +++ b/app/javascript/flavours/glitch/reducers/local_settings.js @@ -25,7 +25,8 @@ const initialState = ImmutableMap({ tag_misleading_links: true, rewrite_mentions: 'no', content_warnings : ImmutableMap({ - filter : null, + filter : null, + media_outside: false, }), collapsed : ImmutableMap({ enabled : true, -- cgit From db5b44330d3139132645fda99682caa15aae2768 Mon Sep 17 00:00:00 2001 From: Claire Date: Sun, 24 Jul 2022 11:11:38 +0200 Subject: Add explanation for some options in the local settings dialog --- app/javascript/flavours/glitch/features/local_settings/page/index.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/features/local_settings/page/index.js b/app/javascript/flavours/glitch/features/local_settings/page/index.js index 44d0221c6..2f16ed50c 100644 --- a/app/javascript/flavours/glitch/features/local_settings/page/index.js +++ b/app/javascript/flavours/glitch/features/local_settings/page/index.js @@ -375,6 +375,7 @@ class LocalSettingsPage extends React.PureComponent { onChange={onChange} > + +
-- cgit From a5f81e1abd82cb66e590b73af83c720d6410fafd Mon Sep 17 00:00:00 2001 From: Claire Date: Sun, 24 Jul 2022 13:16:03 +0200 Subject: Improve interaction between out-of-CW attachments and collapsed toots --- app/javascript/flavours/glitch/components/status.js | 3 +-- app/javascript/flavours/glitch/components/status_content.js | 6 ++++++ .../flavours/glitch/features/status/components/detailed_status.js | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index d3bdcdc91..219f7de7a 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -771,6 +771,7 @@ class Status extends ImmutablePureComponent { - {extraMedia} - {!isCollapsed || !(muted || !settings.getIn(['collapsed', 'show_action_bar'])) ? ( + {extraMedia} +
); } else if (parseClick) { @@ -372,6 +376,7 @@ export default class StatusContent extends React.PureComponent { lang={lang} /> {media} + {extraMedia} ); } else { @@ -391,6 +396,7 @@ export default class StatusContent extends React.PureComponent { lang={lang} /> {media} + {extraMedia} ); } diff --git a/app/javascript/flavours/glitch/features/status/components/detailed_status.js b/app/javascript/flavours/glitch/features/status/components/detailed_status.js index bfbfabcb6..301a2add6 100644 --- a/app/javascript/flavours/glitch/features/status/components/detailed_status.js +++ b/app/javascript/flavours/glitch/features/status/components/detailed_status.js @@ -296,6 +296,7 @@ class DetailedStatus extends ImmutablePureComponent { - {extraMedia} -