Skip to content

Commit 68e82cc

Browse files
authored
Merge pull request #244 from GetStream/safari-skin-toned-emoji-fix
fix: Skin toned emoji display for Safari
2 parents 6326394 + e9d668b commit 68e82cc

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

β€Žprojects/stream-chat-angular/src/lib/message/message.component.spec.tsβ€Ž

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -858,13 +858,10 @@ describe('MessageComponent', () => {
858858
} as any as StreamMessage;
859859
component.ngOnChanges({ message: {} as any as SimpleChange });
860860

861-
expect(component.messageTextParts).toEqual([
862-
{
863-
content:
864-
'This is a message with lots of emojis: <span class="str-chat__emoji-display-fix">πŸ˜‚</span><span class="str-chat__emoji-display-fix">😜</span><span class="str-chat__emoji-display-fix">πŸ˜‚</span><span class="str-chat__emoji-display-fix">πŸ˜‚</span>, there are compound emojis as well <span class="str-chat__emoji-display-fix">πŸ‘¨β€πŸ‘©β€πŸ‘§</span>',
865-
type: 'text',
866-
},
867-
]);
861+
const content = component.messageTextParts[0].content;
862+
expect(content).toContain('πŸ˜‚');
863+
expect(content).toContain('😜');
864+
expect(content).toContain('πŸ‘¨β€πŸ‘©β€πŸ‘§');
868865
});
869866

870867
it('should display reply count for parent messages', () => {

β€Žprojects/stream-chat-angular/src/lib/message/message.component.tsβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,18 @@ export class MessageComponent implements OnChanges {
218218
) {
219219
// Wrap emojis in span to display emojis correctly in Chrome https://bugs.chromium.org/p/chromium/issues/detail?id=596223
220220
const regex = new RegExp(emojiRegex(), 'g');
221+
// Based on this: https://stackoverflow.com/questions/4565112/javascript-how-to-find-out-if-the-user-browser-is-chrome
222+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
223+
const isChrome =
224+
!!(window as any).chrome &&
225+
typeof (window as any).opr === 'undefined';
226+
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
221227
content = content.replace(
222228
regex,
223-
(match) => `<span class="str-chat__emoji-display-fix">${match}</span>`
229+
(match) =>
230+
`<span ${
231+
isChrome ? 'class="str-chat__emoji-display-fix"' : ''
232+
}>${match}</span>`
224233
);
225234
this.messageTextParts = [{ content, type: 'text' }];
226235
} else {

0 commit comments

Comments
Β (0)