Fix removing my reaction flag on status updated
This commit is contained in:
parent
498dc2ccce
commit
21899ccf3f
1 changed files with 14 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
import escapeTextContentForBrowser from 'escape-html';
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
import emojify from '../../features/emoji/emoji';
|
import emojify from '../../features/emoji/emoji';
|
||||||
import { unescapeHTML } from '../../utils/html';
|
import { unescapeHTML } from '../../utils/html';
|
||||||
import { expandSpoilers } from '../../initial_state';
|
import { expandSpoilers, me } from '../../initial_state';
|
||||||
|
|
||||||
const domParser = new DOMParser();
|
const domParser = new DOMParser();
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ export function normalizeStatus(status, normalOldStatus) {
|
||||||
normalStatus.filtered = status.filtered.map(normalizeFilterResult);
|
normalStatus.filtered = status.filtered.map(normalizeFilterResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.emoji_reactions) {
|
if (status.emoji_reactions && normalOldStatus) {
|
||||||
normalStatus.emojiReactions = status.emoji_reactions;
|
normalStatus.emoji_reactions = normalizeEmojiReactions(normalOldStatus.get('emoji_reactions').toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only calculate these values when status first encountered and
|
// Only calculate these values when status first encountered and
|
||||||
|
@ -100,6 +100,17 @@ export function normalizeStatus(status, normalOldStatus) {
|
||||||
return normalStatus;
|
return normalStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function normalizeEmojiReactions(emoji_reactions) {
|
||||||
|
const myAccountId = me;
|
||||||
|
let converted = [];
|
||||||
|
for (let emoji_reaction of emoji_reactions) {
|
||||||
|
let obj = emoji_reaction.toObject();
|
||||||
|
obj.me = obj.account_ids.toArray().some((id) => id === myAccountId);
|
||||||
|
converted.push(obj);
|
||||||
|
}
|
||||||
|
return converted;
|
||||||
|
}
|
||||||
|
|
||||||
export function normalizePoll(poll) {
|
export function normalizePoll(poll) {
|
||||||
const normalPoll = { ...poll };
|
const normalPoll = { ...poll };
|
||||||
const emojiMap = makeEmojiMap(normalPoll);
|
const emojiMap = makeEmojiMap(normalPoll);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue