Don't add like reacts when there are no favourites

stable/1.0.x
Alex Gleason 2020-05-20 11:55:30 -05:00
rodzic d562a25c78
commit 3547fd093a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 7 dodań i 0 usunięć

Wyświetl plik

@ -79,6 +79,12 @@ describe('mergeEmojiFavourites', () => {
{ 'count': 12, 'me': false, 'name': '👍' }, { 'count': 12, 'me': false, 'name': '👍' },
])); ]));
}); });
it('does not add 👍 reacts when there are no favourites', () => {
expect(mergeEmojiFavourites(emojiReacts, 0)).toEqual(fromJS([
{ 'count': 15, 'me': true, 'name': '❤️' },
{ 'count': 7, 'me': true, 'name': '😯' },
]));
});
}); });
}); });

Wyświetl plik

@ -19,6 +19,7 @@ export const mergeEmoji = emojiReacts => (
); );
export const mergeEmojiFavourites = (emojiReacts, favouritesCount) => { export const mergeEmojiFavourites = (emojiReacts, favouritesCount) => {
if (!favouritesCount) return emojiReacts;
const likeIndex = emojiReacts.findIndex(emojiReact => const likeIndex = emojiReacts.findIndex(emojiReact =>
emojiReact.get('name') === '👍'); emojiReact.get('name') === '👍');
if (likeIndex > -1) { if (likeIndex > -1) {