Fix #6762: Do not overwrite some status attributes in reducer (#6767)

rebase/4.0.0rc2
Eugen Rochko 2018-03-13 07:16:43 +01:00 committed by GitHub
parent d9500c8a3b
commit 386365090c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 9 deletions

View File

@ -56,17 +56,21 @@ const normalizeStatus = (state, status) => {
normalStatus.reblog = status.reblog.id;
}
const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
// Only calculate these values when status first encountered
// Otherwise keep the ones already in the reducer
if (!state.has(status.id)) {
const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
obj[`:${emoji.shortcode}:`] = emoji;
return obj;
}, {});
const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
obj[`:${emoji.shortcode}:`] = emoji;
return obj;
}, {});
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.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;
}
return state.update(status.id, ImmutableMap(), map => map.mergeDeep(fromJS(normalStatus)));
};