Skip to content

Commit

Permalink
Remove unused Emoji component
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Oct 13, 2023
1 parent deb6a4e commit 29f0738
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
4 changes: 1 addition & 3 deletions src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ export type ChannelProps<
dragAndDropWindow?: boolean;
/** Custom UI component to override default edit message input, defaults to and accepts same props as: [EditMessageForm](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/EditMessageForm.tsx) */
EditMessageInput?: ComponentContextValue<StreamChatGenerics>['EditMessageInput'];
/** Custom UI component to override default `NimbleEmoji` from `emoji-mart` */
Emoji?: EmojiContextValue['Emoji'];

/** Custom prop to override default `facebook.json` emoji data set from `emoji-mart` */
emojiData?: EmojiMartData;
/** Custom UI component for emoji button in input, defaults to and accepts same props as: [EmojiIconSmall](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/icons.tsx) */
Expand Down Expand Up @@ -1008,7 +1007,6 @@ const ChannelInner = <

const emojiContextValue: EmojiContextValue = useMemo(
() => ({
Emoji: props.Emoji,
emojiConfig,
EmojiIndex: props.EmojiIndex,
EmojiPicker: props.EmojiPicker,
Expand Down
4 changes: 1 addition & 3 deletions src/components/Channel/__tests__/Channel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,15 @@ describe('Channel', () => {
emojis: {},
};
const CustomEmojiPicker = () => <div />;
const CustomEmoji = () => <span />;

renderComponent({ Emoji: CustomEmoji, emojiData, EmojiPicker: CustomEmojiPicker }, (ctx) => {
renderComponent({ emojiData, EmojiPicker: CustomEmojiPicker }, (ctx) => {
context = ctx;
});

await waitFor(() => {
expect(context).toBeInstanceOf(Object);
expect(context.emojiConfig.emojiData).toBe(emojiData);
expect(context.EmojiPicker).toBe(CustomEmojiPicker);
expect(context.Emoji).toBe(CustomEmoji);
});
});

Expand Down
12 changes: 1 addition & 11 deletions src/context/EmojiContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
Data as EmojiMartData,
EmojiSheetSize,
NimbleEmojiIndex,
NimbleEmojiProps,
NimblePickerProps,
} from 'emoji-mart';

Expand Down Expand Up @@ -44,13 +43,10 @@ export type EmojiConfig = {

export type EmojiContextValue = {
emojiConfig: EmojiConfig;
Emoji?: React.ComponentType<NimbleEmojiProps>;
EmojiIndex?: NimbleEmojiIndex;
EmojiPicker?: React.ComponentType<NimblePickerProps>;
};

const DefaultEmoji = React.lazy(() => import('./DefaultEmoji'));

const DefaultEmojiPicker = React.lazy(() => import('./DefaultEmojiPicker'));

export const EmojiContext = React.createContext<EmojiContextValue | undefined>(undefined);
Expand All @@ -61,15 +57,9 @@ export const EmojiProvider = ({
}: PropsWithChildren<{
value: EmojiContextValue;
}>) => {
const {
Emoji = DefaultEmoji,
emojiConfig,
EmojiIndex = DefaultEmojiIndex,
EmojiPicker = DefaultEmojiPicker,
} = value;
const { emojiConfig, EmojiIndex = DefaultEmojiIndex, EmojiPicker = DefaultEmojiPicker } = value;

const emojiContextValue: Required<EmojiContextValue> = {
Emoji,
emojiConfig,
EmojiIndex,
EmojiPicker,
Expand Down

0 comments on commit 29f0738

Please sign in to comment.