Skip to content

Commit 1c89909

Browse files
Move quote post fallback removal import-time (mastodon#36055)
1 parent 13d970b commit 1c89909

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

app/javascript/mastodon/actions/importer/normalizer.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ export function normalizeFilterResult(result) {
2121
return normalResult;
2222
}
2323

24+
function stripQuoteFallback(text) {
25+
const wrapper = document.createElement('div');
26+
wrapper.innerHTML = text;
27+
28+
wrapper.querySelector('.quote-inline')?.remove();
29+
30+
return wrapper.innerHTML;
31+
}
32+
2433
export function normalizeStatus(status, normalOldStatus) {
2534
const normalStatus = { ...status };
2635

@@ -86,6 +95,11 @@ export function normalizeStatus(status, normalOldStatus) {
8695
normalStatus.spoilerHtml = emojify(escapeTextContentForBrowser(spoilerText), emojiMap);
8796
normalStatus.hidden = expandSpoilers ? false : spoilerText.length > 0 || normalStatus.sensitive;
8897

98+
// Remove quote fallback link from the DOM so it doesn't mess with paragraph margins
99+
if (normalStatus.quote) {
100+
normalStatus.contentHtml = stripQuoteFallback(normalStatus.contentHtml);
101+
}
102+
89103
if (normalStatus.url && !(normalStatus.url.startsWith('http://') || normalStatus.url.startsWith('https://'))) {
90104
normalStatus.url = null;
91105
}
@@ -125,6 +139,11 @@ export function normalizeStatusTranslation(translation, status) {
125139
spoiler_text: translation.spoiler_text,
126140
};
127141

142+
// Remove quote fallback link from the DOM so it doesn't mess with paragraph margins
143+
if (status.get('quote')) {
144+
normalTranslation.contentHtml = stripQuoteFallback(normalTranslation.contentHtml);
145+
}
146+
128147
return normalTranslation;
129148
}
130149

app/javascript/mastodon/components/status_content.jsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,6 @@ class StatusContent extends PureComponent {
138138

139139
onCollapsedToggle(collapsed);
140140
}
141-
142-
// Remove quote fallback link from the DOM so it doesn't
143-
// mess with paragraph margins
144-
if (!!status.get('quote')) {
145-
const inlineQuote = node.querySelector('.quote-inline');
146-
147-
if (inlineQuote) {
148-
inlineQuote.remove();
149-
}
150-
}
151141
}
152142

153143
handleMouseEnter = ({ currentTarget }) => {

0 commit comments

Comments
 (0)