[Glitch] Do not overwrite some status attributes in reducer

Backport 386365090c
signup-info-prompt
Thibaut Girka 2018-03-29 17:52:41 +02:00
parent 64d8d0464d
commit b383c0688a
1 changed files with 12 additions and 8 deletions

View File

@ -62,16 +62,20 @@ const normalizeStatus = (state, status) => {
normalStatus.reblog = status.reblog.id;
}
const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br \/>/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 \/>/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.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent;
normalStatus.contentHtml = emojify(normalStatus.content, emojiMap);
normalStatus.spoilerHtml = emojify(escapeTextContentForBrowser(normalStatus.spoiler_text || ''), emojiMap);
}
return state.update(status.id, ImmutableMap(), map => map.mergeDeep(fromJS(normalStatus)));
};