Zip shortcodes in with emoji objects

Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
Robin Townsend 2021-07-16 16:36:03 -04:00
parent 8efb30eb07
commit f88d5dd24e
5 changed files with 37 additions and 50 deletions

View file

@ -17,7 +17,7 @@ limitations under the License.
import React from 'react';
import { IEmoji, getShortcodes } from "../../../emoji";
import { IEmoji } from "../../../emoji";
import { replaceableComponent } from "../../../utils/replaceableComponent";
interface IProps {
@ -27,11 +27,7 @@ interface IProps {
@replaceableComponent("views.emojipicker.Preview")
class Preview extends React.PureComponent<IProps> {
render() {
const {
unicode = "",
annotation = "",
} = this.props.emoji;
const shortcode = getShortcodes(this.props.emoji)[0];
const { unicode, annotation, shortcodes: [shortcode] } = this.props.emoji;
return (
<div className="mx_EmojiPicker_footer mx_EmojiPicker_preview">

View file

@ -18,7 +18,7 @@ limitations under the License.
import React from 'react';
import { _t } from '../../../languageHandler';
import { getEmojiFromUnicode, getShortcodes, IEmoji } from "../../../emoji";
import { getEmojiFromUnicode, IEmoji } from "../../../emoji";
import Emoji from "./Emoji";
import { replaceableComponent } from "../../../utils/replaceableComponent";
@ -62,7 +62,7 @@ class QuickReactions extends React.Component<IProps, IState> {
};
render() {
const shortcode = this.state.hover ? getShortcodes(this.state.hover)[0] : undefined;
const shortcode = this.state.hover?.shortcodes?.[0];
return (
<section className="mx_EmojiPicker_footer mx_EmojiPicker_quick mx_EmojiPicker_category">
<h2 className="mx_EmojiPicker_quick_header mx_EmojiPicker_category_label">