MM-36900 Fix mm emoji (#5526)
* wip * fix typo * fix snapshots * move inside emojis Co-authored-by: = <=>
This commit is contained in:
parent
eed5b41292
commit
ec417cfd56
7 changed files with 61 additions and 8 deletions
|
|
@ -1403,6 +1403,7 @@ exports[`components/autocomplete/emoji_suggestion should match snapshot 2`] = `
|
||||||
"massage_man",
|
"massage_man",
|
||||||
"massage_woman",
|
"massage_woman",
|
||||||
"mate_drink",
|
"mate_drink",
|
||||||
|
"mattermost",
|
||||||
"mauritania",
|
"mauritania",
|
||||||
"mauritius",
|
"mauritius",
|
||||||
"mayotte",
|
"mayotte",
|
||||||
|
|
@ -3742,6 +3743,7 @@ exports[`components/autocomplete/emoji_suggestion should match snapshot 2`] = `
|
||||||
"massage_man",
|
"massage_man",
|
||||||
"massage_woman",
|
"massage_woman",
|
||||||
"mate_drink",
|
"mate_drink",
|
||||||
|
"mattermost",
|
||||||
"mauritania",
|
"mauritania",
|
||||||
"mauritius",
|
"mauritius",
|
||||||
"mayotte",
|
"mayotte",
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import {
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import FastImage, {ImageStyle} from 'react-native-fast-image';
|
import FastImage, {ImageStyle} from 'react-native-fast-image';
|
||||||
|
|
||||||
|
const assetImages = new Map([['mattermost.png', require('@assets/images/emojis/mattermost.png')]]);
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -23,6 +25,11 @@ type Props = {
|
||||||
*/
|
*/
|
||||||
imageUrl: string;
|
imageUrl: string;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* asset name in case it is bundled with the app
|
||||||
|
*/
|
||||||
|
assetImage: string;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set if this is a custom emoji.
|
* Set if this is a custom emoji.
|
||||||
*/
|
*/
|
||||||
|
|
@ -45,6 +52,7 @@ const Emoji: React.FC<Props> = (props: Props) => {
|
||||||
customEmojiStyle,
|
customEmojiStyle,
|
||||||
displayTextOnly,
|
displayTextOnly,
|
||||||
imageUrl,
|
imageUrl,
|
||||||
|
assetImage,
|
||||||
literal,
|
literal,
|
||||||
unicode,
|
unicode,
|
||||||
testID,
|
testID,
|
||||||
|
|
@ -88,6 +96,24 @@ const Emoji: React.FC<Props> = (props: Props) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (assetImage) {
|
||||||
|
const key = Platform.OS === 'android' ? (`${assetImage}-${height}-${width}`) : null;
|
||||||
|
|
||||||
|
const image = assetImages.get(assetImage);
|
||||||
|
if (!image) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<FastImage
|
||||||
|
key={key}
|
||||||
|
source={image}
|
||||||
|
style={[customEmojiStyle, {width, height}]}
|
||||||
|
resizeMode={FastImage.resizeMode.contain}
|
||||||
|
testID={testID}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!imageUrl) {
|
if (!imageUrl) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,17 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
|
||||||
|
|
||||||
let imageUrl = '';
|
let imageUrl = '';
|
||||||
let unicode;
|
let unicode;
|
||||||
|
let assetImage = '';
|
||||||
let isCustomEmoji = false;
|
let isCustomEmoji = false;
|
||||||
let displayTextOnly = false;
|
let displayTextOnly = false;
|
||||||
if (EmojiIndicesByAlias.has(emojiName)) {
|
if (EmojiIndicesByAlias.has(emojiName)) {
|
||||||
const emoji = Emojis[EmojiIndicesByAlias.get(emojiName)!];
|
const emoji = Emojis[EmojiIndicesByAlias.get(emojiName)!];
|
||||||
unicode = emoji.image;
|
if (emoji.category === 'custom') {
|
||||||
|
assetImage = emoji.fileName;
|
||||||
|
isCustomEmoji = true;
|
||||||
|
} else {
|
||||||
|
unicode = emoji.image;
|
||||||
|
}
|
||||||
} else if (customEmojis.has(emojiName) && serverUrl) {
|
} else if (customEmojis.has(emojiName) && serverUrl) {
|
||||||
const emoji = customEmojis.get(emojiName);
|
const emoji = customEmojis.get(emojiName);
|
||||||
imageUrl = Client4.getCustomEmojiImageUrl(emoji!.id);
|
imageUrl = Client4.getCustomEmojiImageUrl(emoji!.id);
|
||||||
|
|
@ -45,6 +51,7 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
imageUrl,
|
imageUrl,
|
||||||
|
assetImage,
|
||||||
isCustomEmoji,
|
isCustomEmoji,
|
||||||
displayTextOnly,
|
displayTextOnly,
|
||||||
unicode,
|
unicode,
|
||||||
|
|
|
||||||
|
|
@ -12861,7 +12861,25 @@ exports[`components/emoji_picker/emoji_picker.ios should match snapshot 1`] = `
|
||||||
"key": "flags",
|
"key": "flags",
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"data": Array [],
|
"data": Array [
|
||||||
|
Object {
|
||||||
|
"items": Array [
|
||||||
|
Object {
|
||||||
|
"aliases": Array [
|
||||||
|
"mattermost",
|
||||||
|
],
|
||||||
|
"name": "mattermost",
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
],
|
||||||
|
"key": "custom-0",
|
||||||
|
},
|
||||||
|
],
|
||||||
"defaultMessage": undefined,
|
"defaultMessage": undefined,
|
||||||
"icon": "emoticon-custom-outline",
|
"icon": "emoticon-custom-outline",
|
||||||
"id": "emoji_picker.custom",
|
"id": "emoji_picker.custom",
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
assets/base/images/emojis/mattermost.png
Normal file
BIN
assets/base/images/emojis/mattermost.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2 KiB |
Loading…
Reference in a new issue