FIX: ensures diversity code is not applied multiple times (#10517)

This commit is contained in:
Joffrey JAFFEUX 2020-08-24 16:10:47 +02:00 committed by GitHub
parent 265d8bc1d7
commit b6dd3eca9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -176,7 +176,10 @@ export default Component.extend({
return false;
}
this.set("hoveredEmoji", event.target.title);
this.set(
"hoveredEmoji",
this._codeWithDiversity(event.target.title, this.selectedDiversity)
);
},
@action
@ -241,7 +244,9 @@ export default Component.extend({
},
_codeWithDiversity(code, selectedDiversity) {
if (selectedDiversity !== 0 && isSkinTonableEmoji(code)) {
if (/:t\d/.test(code)) {
return code;
} else if (selectedDiversity !== 0 && isSkinTonableEmoji(code)) {
return `${code}:t${selectedDiversity + 1}`;
} else {
return code;