about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2018-06-14 15:03:51 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-06-14 08:03:51 +0200
commitf972815f1bdc7a9ca198da938471c1299a96b401 (patch)
treeb8103cf40c6ee5fbd96e4f09288d90102ae55292 /app
parent79a468016a4f267fc954ef521a65d97e3e1370cf (diff)
Hide status content when spoiler text is not empty (#7797)
Diffstat (limited to 'app')
-rw-r--r--app/javascript/mastodon/actions/importer/normalizer.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/javascript/mastodon/actions/importer/normalizer.js b/app/javascript/mastodon/actions/importer/normalizer.js
index c015d3a99..10a39e050 100644
--- a/app/javascript/mastodon/actions/importer/normalizer.js
+++ b/app/javascript/mastodon/actions/importer/normalizer.js
@@ -50,13 +50,14 @@ export function normalizeStatus(status, normalOldStatus) {
     normalStatus.spoilerHtml = normalOldStatus.get('spoilerHtml');
     normalStatus.hidden = normalOldStatus.get('hidden');
   } else {
-    const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
-    const emojiMap = makeEmojiMap(normalStatus);
+    const spoilerText   = normalStatus.spoiler_text || '';
+    const searchContent = [spoilerText, status.content].join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
+    const emojiMap      = makeEmojiMap(normalStatus);
 
     normalStatus.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent;
     normalStatus.contentHtml  = emojify(normalStatus.content, emojiMap);
-    normalStatus.spoilerHtml  = emojify(escapeTextContentForBrowser(normalStatus.spoiler_text || ''), emojiMap);
-    normalStatus.hidden       = normalStatus.sensitive;
+    normalStatus.spoilerHtml  = emojify(escapeTextContentForBrowser(spoilerText), emojiMap);
+    normalStatus.hidden       = spoilerText.length > 0 || normalStatus.sensitive;
   }
 
   return normalStatus;