about summary refs log tree commit diff
path: root/app/javascript/mastodon/actions
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-05-05 23:41:02 +0200
committerGitHub <noreply@github.com>2021-05-05 23:41:02 +0200
commitaa1b43f46786ad23098159f1210b1811c64de72a (patch)
treeee73bd71db9799634d58753581b00e593756c760 /app/javascript/mastodon/actions
parent7cb34b32f8bc925b56c79dbcf053671f93f2eb42 (diff)
Fix display of toots without text content (#15665)
* Fix display of toots without text content

- fixes CWs from other implementations not showing up if toot has no text
  contents
- fixes the “Read more” thread indicator not showing up on threaded toots
  with no text contents

* Move content-less toot's CW to conents
Diffstat (limited to 'app/javascript/mastodon/actions')
-rw-r--r--app/javascript/mastodon/actions/importer/normalizer.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/javascript/mastodon/actions/importer/normalizer.js b/app/javascript/mastodon/actions/importer/normalizer.js
index 087f26491..abd5681d4 100644
--- a/app/javascript/mastodon/actions/importer/normalizer.js
+++ b/app/javascript/mastodon/actions/importer/normalizer.js
@@ -62,6 +62,13 @@ export function normalizeStatus(status, normalOldStatus) {
     normalStatus.spoilerHtml = normalOldStatus.get('spoilerHtml');
     normalStatus.hidden = normalOldStatus.get('hidden');
   } else {
+    // If the status has a CW but no contents, treat the CW as if it were the
+    // status' contents, to avoid having a CW toggle with seemingly no effect.
+    if (normalStatus.spoiler_text && !normalStatus.content) {
+      normalStatus.content = normalStatus.spoiler_text;
+      normalStatus.spoiler_text = '';
+    }
+
     const spoilerText   = normalStatus.spoiler_text || '';
     const searchContent = ([spoilerText, status.content].concat((status.poll && status.poll.options) ? status.poll.options.map(option => option.title) : [])).join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
     const emojiMap      = makeEmojiMap(normalStatus);