diff --git a/app/containers/Avatar/Avatar.stories.tsx b/app/containers/Avatar/Avatar.stories.tsx index 224cedaaa6f..b251b35d0c6 100644 --- a/app/containers/Avatar/Avatar.stories.tsx +++ b/app/containers/Avatar/Avatar.stories.tsx @@ -1,9 +1,13 @@ import { StyleSheet } from 'react-native'; +import { setCustomEmojis } from '../../actions/customEmojis'; +import { mockedStore } from '../../reducers/mockedStore'; import Status from '../Status/Status'; import sharedStyles from '../../views/Styles'; import Avatar from './Avatar'; +mockedStore.dispatch(setCustomEmojis({ troll: { name: 'troll', extension: 'jpg' } })); + const styles = StyleSheet.create({ custom: { padding: 16 @@ -40,9 +44,7 @@ export const WithETag = () => ( export const WithoutETag = () => ; -export const Emoji = () => ( - ({ name: 'troll', extension: 'jpg' })} server={server} size={56} /> -); +export const Emoji = () => ; export const Direct = () => ; diff --git a/app/containers/Avatar/Avatar.tsx b/app/containers/Avatar/Avatar.tsx index 834012c6485..6d375147249 100644 --- a/app/containers/Avatar/Avatar.tsx +++ b/app/containers/Avatar/Avatar.tsx @@ -7,7 +7,6 @@ import Emoji from '../markdown/components/emoji/Emoji'; import { getAvatarURL } from '../../lib/methods/helpers/getAvatarUrl'; import { SubscriptionType } from '../../definitions'; import { type IAvatar } from './interfaces'; -import MarkdownContext from '../markdown/contexts/MarkdownContext'; import I18n from '../../i18n'; import Touch from '../Touch'; @@ -21,7 +20,6 @@ const Avatar = memo( token, onPress, emoji, - getCustomEmoji, avatarETag, isStatic, rid, @@ -51,16 +49,11 @@ const Avatar = memo( let image; if (emoji) { image = ( - - - + ); } else { let uri = avatar; diff --git a/app/containers/Avatar/AvatarContainer.tsx b/app/containers/Avatar/AvatarContainer.tsx index 11db5c78ba4..9889fb95319 100644 --- a/app/containers/Avatar/AvatarContainer.tsx +++ b/app/containers/Avatar/AvatarContainer.tsx @@ -17,7 +17,6 @@ const AvatarContainer = ({ type, children, onPress, - getCustomEmoji, isStatic, rid, accessibilityLabel, @@ -61,7 +60,6 @@ const AvatarContainer = ({ userId={id} token={token} onPress={onPress} - getCustomEmoji={getCustomEmoji} isStatic={isStatic} rid={rid} blockUnauthenticatedAccess={blockUnauthenticatedAccess} diff --git a/app/containers/Avatar/AvatarWithEdit.tsx b/app/containers/Avatar/AvatarWithEdit.tsx index d736a6c8cdc..2b7a26a8b0e 100644 --- a/app/containers/Avatar/AvatarWithEdit.tsx +++ b/app/containers/Avatar/AvatarWithEdit.tsx @@ -39,7 +39,6 @@ const AvatarWithEdit = ({ type, children, onPress, - getCustomEmoji, isStatic, rid, handleEdit, @@ -62,7 +61,6 @@ const AvatarWithEdit = ({ borderRadius={borderRadius} type={type} onPress={onPress} - getCustomEmoji={getCustomEmoji} isStatic={isStatic} rid={rid}> {children} diff --git a/app/containers/Avatar/interfaces.ts b/app/containers/Avatar/interfaces.ts index aac0a8ef262..d66edad90e8 100644 --- a/app/containers/Avatar/interfaces.ts +++ b/app/containers/Avatar/interfaces.ts @@ -1,8 +1,6 @@ import { type ReactElement } from 'react'; import { type ViewStyle } from 'react-native'; -import { type TGetCustomEmoji } from '../../definitions/IEmoji'; - export interface IAvatar { server?: string; style?: ViewStyle; @@ -16,7 +14,6 @@ export interface IAvatar { userId?: string; token?: string; onPress?: () => void; - getCustomEmoji?: TGetCustomEmoji; avatarETag?: string; isStatic?: boolean | string; rid?: string; diff --git a/app/containers/ReactionsList/AllTab.tsx b/app/containers/ReactionsList/AllTab.tsx index 2184697e3d3..92ee7e9427e 100644 --- a/app/containers/ReactionsList/AllTab.tsx +++ b/app/containers/ReactionsList/AllTab.tsx @@ -4,22 +4,19 @@ import { Text, View, FlatList } from 'react-native'; import Emoji from '../message/Emoji'; import { useTheme } from '../../theme'; import { type IReaction } from '../../definitions'; -import { type TGetCustomEmoji } from '../../definitions/IEmoji'; import I18n from '../../i18n'; import styles from './styles'; import { useAppSelector } from '../../lib/hooks/useAppSelector'; interface IAllReactionsListItemProps { - getCustomEmoji: TGetCustomEmoji; item: IReaction; } interface IAllTabProps { - getCustomEmoji: TGetCustomEmoji; reactions?: IReaction[]; } -const AllReactionsListItem = ({ item, getCustomEmoji }: IAllReactionsListItemProps) => { +const AllReactionsListItem = ({ item }: IAllReactionsListItemProps) => { const { colors } = useTheme(); const useRealName = useAppSelector(state => state.settings.UI_Use_Real_Name); const username = useAppSelector(state => state.login.user.username); @@ -48,7 +45,6 @@ const AllReactionsListItem = ({ item, getCustomEmoji }: IAllReactionsListItemPro content={item.emoji} standardEmojiStyle={styles.allTabStandardEmojiStyle} customEmojiStyle={styles.allTabCustomEmojiStyle} - getCustomEmoji={getCustomEmoji} /> @@ -60,12 +56,12 @@ const AllReactionsListItem = ({ item, getCustomEmoji }: IAllReactionsListItemPro ); }; -const AllTab = ({ reactions, getCustomEmoji }: IAllTabProps): ReactElement => ( +const AllTab = ({ reactions }: IAllTabProps): ReactElement => ( } + renderItem={({ item }) => } keyExtractor={item => item.emoji} /> diff --git a/app/containers/ReactionsList/ReactionsList.stories.tsx b/app/containers/ReactionsList/ReactionsList.stories.tsx index 01f907525ed..9719194310d 100644 --- a/app/containers/ReactionsList/ReactionsList.stories.tsx +++ b/app/containers/ReactionsList/ReactionsList.stories.tsx @@ -1,18 +1,17 @@ import { View } from 'react-native'; -import { type TGetCustomEmoji, type ICustomEmoji } from '../../definitions'; import ReactionsList from '.'; import { mockedStore as store } from '../../reducers/mockedStore'; import { updateSettings } from '../../actions/settings'; +import { setCustomEmojis } from '../../actions/customEmojis'; -const getCustomEmoji: TGetCustomEmoji = content => { - const customEmoji = { - marioparty: { name: content, extension: 'gif' }, - react_rocket: { name: content, extension: 'png' }, - nyan_rocket: { name: content, extension: 'png' } - }[content] as ICustomEmoji; - return customEmoji; -}; +store.dispatch( + setCustomEmojis({ + marioparty: { name: 'marioparty', extension: 'gif' }, + react_rocket: { name: 'react_rocket', extension: 'png' }, + nyan_rocket: { name: 'nyan_rocket', extension: 'png' } + }) +); const reactions = [ { @@ -51,7 +50,7 @@ export const ReactionsListStory = () => { store.dispatch(updateSettings('UI_Use_Real_Name', false)); return ( - + ); }; @@ -60,7 +59,7 @@ export const ReactionsListFullName = () => { store.dispatch(updateSettings('UI_Use_Real_Name', true)); return ( - + ); }; diff --git a/app/containers/ReactionsList/ReactionsList.test.tsx b/app/containers/ReactionsList/ReactionsList.test.tsx index dc431e8b2bc..25209464920 100644 --- a/app/containers/ReactionsList/ReactionsList.test.tsx +++ b/app/containers/ReactionsList/ReactionsList.test.tsx @@ -2,6 +2,7 @@ import { type ReactElement, type ReactNode } from 'react'; import { screen, render, fireEvent, within } from '@testing-library/react-native'; import { Provider } from 'react-redux'; import { createStore } from 'redux'; +import { Image as ExpoImage } from 'expo-image'; import ReactionsList from './index'; import { type IReaction } from '../../definitions'; @@ -105,16 +106,12 @@ const mockStore = createStore( server: { server: 'https://open.rocket.chat', version: '6.0.0' - } + }, + customEmojis: {} } ) => state ); -const mockGetCustomEmoji = (emoji: string) => ({ - name: emoji, - extension: 'png' -}); - const mockReactions: IReaction[] = [ { _id: 'reaction1', @@ -138,13 +135,13 @@ describe('ReactionsList Integration Tests', () => { }); it('renders empty ReactionsList when no reactions', () => { - renderWithRedux(); + renderWithRedux(); expect(screen.getByTestId('reactionsList')).toBeOnTheScreen(); expect(screen.getByTestId('reactionsListAllTab')).toBeOnTheScreen(); }); it('renders ReactionsList with reactions and allows navigation between tabs', () => { - renderWithRedux(); + renderWithRedux(); // Verify All tab content expect(screen.getByText('4 people reacted')).toBeOnTheScreen(); @@ -185,14 +182,15 @@ describe('ReactionsList Integration Tests', () => { server: { server: 'https://open.rocket.chat', version: '6.0.0' - } + }, + customEmojis: {} } ) => state ); render( - + ); @@ -218,6 +216,30 @@ describe('ReactionsList Integration Tests', () => { }); it('handles custom emojis correctly', () => { + const storeWithCustomEmoji = createStore( + ( + state = { + settings: { + UI_Use_Real_Name: true + }, + login: { + user: { + id: 'user123', + username: 'testuser', + name: 'Test User' + } + }, + server: { + server: 'https://open.rocket.chat', + version: '6.0.0' + }, + customEmojis: { + custom_emoji: { name: 'custom_emoji', extension: 'png' } + } + } + ) => state + ); + const customReactions: IReaction[] = [ { _id: 'reaction3', @@ -227,11 +249,18 @@ describe('ReactionsList Integration Tests', () => { } ]; - renderWithRedux(); + render( + + + + ); - // Verify custom emoji is rendered expect(screen.getByTestId('tab-:custom_emoji:')).toBeOnTheScreen(); expect(screen.getByText('1 person reacted')).toBeOnTheScreen(); + + // Resolves against the store and renders as a custom emoji image, not the shortname text + expect(screen.UNSAFE_getAllByType(ExpoImage).length).toBeGreaterThan(0); + expect(screen.queryByText(':custom_emoji:')).toBeNull(); }); }); diff --git a/app/containers/ReactionsList/index.tsx b/app/containers/ReactionsList/index.tsx index 3057aa2c8d3..ea7748fd4a2 100644 --- a/app/containers/ReactionsList/index.tsx +++ b/app/containers/ReactionsList/index.tsx @@ -1,6 +1,5 @@ import { Text, View } from 'react-native'; -import { type TGetCustomEmoji } from '../../definitions/IEmoji'; import { type IReaction } from '../../definitions'; import I18n from '../../i18n'; import styles from './styles'; @@ -10,7 +9,6 @@ import { TabView } from '../TabView'; import Emoji from '../message/Emoji'; interface IReactionsListProps { - getCustomEmoji: TGetCustomEmoji; reactions?: IReaction[]; } @@ -50,12 +48,12 @@ const useRoutes = (reactions: IReaction[] | undefined) => { }; }; -const ReactionsList = ({ reactions, getCustomEmoji }: IReactionsListProps) => { +const ReactionsList = ({ reactions }: IReactionsListProps) => { const { routes, sortedReactions } = useRoutes(reactions); const renderScene = ({ route }: { route: IRoute }) => { if (route.key === 'all') { - return ; + return ; } if (route.emoji && route.usernames && route.names) { return ; @@ -74,12 +72,7 @@ const ReactionsList = ({ reactions, getCustomEmoji }: IReactionsListProps) => { if (tab.emoji) { return ( - + {tab.usernames?.length} ); diff --git a/app/containers/markdown/Markdown.stories.tsx b/app/containers/markdown/Markdown.stories.tsx index ccc89d98cf8..fb9b7fa94c1 100644 --- a/app/containers/markdown/Markdown.stories.tsx +++ b/app/containers/markdown/Markdown.stories.tsx @@ -2,8 +2,9 @@ import { ScrollView, StyleSheet, View } from 'react-native'; import { NavigationContainer } from '@react-navigation/native'; import Markdown, { MarkdownPreview } from '.'; +import { setCustomEmojis } from '../../actions/customEmojis'; +import { mockedStore } from '../../reducers/mockedStore'; import { themes } from '../../lib/constants/colors'; -import { type TGetCustomEmoji, type ICustomEmoji } from '../../definitions/IEmoji'; const theme = 'light'; @@ -27,14 +28,12 @@ d e`; const sequentialEmptySpacesText = 'a b c'; -const getCustomEmoji: TGetCustomEmoji = content => { - const customEmoji = { - marioparty: { name: content, extension: 'gif' }, - react_rocket: { name: content, extension: 'png' }, - nyan_rocket: { name: content, extension: 'png' } - }[content] as ICustomEmoji; - return customEmoji; +const customEmojis = { + marioparty: { name: 'marioparty', extension: 'gif' }, + react_rocket: { name: 'react_rocket', extension: 'png' }, + nyan_rocket: { name: 'nyan_rocket', extension: 'png' } }; +mockedStore.dispatch(setCustomEmojis(customEmojis)); export default { title: 'Markdown', @@ -94,8 +93,8 @@ export const Emoji = () => ( - - + + ); diff --git a/app/containers/markdown/components/emoji/Emoji.tsx b/app/containers/markdown/components/emoji/Emoji.tsx index 9d83009f32d..dab66684618 100644 --- a/app/containers/markdown/components/emoji/Emoji.tsx +++ b/app/containers/markdown/components/emoji/Emoji.tsx @@ -1,4 +1,3 @@ -import { useContext } from 'react'; import { Text, View, useWindowDimensions } from 'react-native'; import { type Emoji as EmojiProps } from '@rocket.chat/message-parser'; @@ -7,8 +6,8 @@ import useShortnameToUnicode from '../../../../lib/hooks/useShortnameToUnicode'; import { useTheme } from '../../../../theme'; import styles from '../../styles'; import CustomEmoji from '../../../EmojiPicker/CustomEmoji'; -import MarkdownContext from '../../contexts/MarkdownContext'; import { useAppSelector } from '../../../../lib/hooks/useAppSelector'; +import { useCustomEmoji } from '../../../../lib/hooks/useCustomEmoji'; import { getUserSelector } from '../../../../selectors/login'; import { useResponsiveLayout } from '../../../../lib/hooks/useResponsiveLayout/useResponsiveLayout'; @@ -34,7 +33,7 @@ function getEmojiToken(block: EmojiProps, isAvatar: boolean) { const Emoji = ({ block, isBigEmoji, style = {}, index, isAvatar = false }: IEmojiProps) => { const { colors } = useTheme(); - const { getCustomEmoji } = useContext(MarkdownContext); + const getCustomEmoji = useCustomEmoji(); const { fontScale } = useWindowDimensions(); const { fontScaleLimited } = useResponsiveLayout(); const { formatShortnameToUnicode } = useShortnameToUnicode(); diff --git a/app/containers/markdown/contexts/MarkdownContext.ts b/app/containers/markdown/contexts/MarkdownContext.ts index dfd8541805e..ee58ef1c1cd 100644 --- a/app/containers/markdown/contexts/MarkdownContext.ts +++ b/app/containers/markdown/contexts/MarkdownContext.ts @@ -9,7 +9,6 @@ interface IMarkdownContext { useRealName?: boolean; username?: string; navToRoomInfo?: Function; - getCustomEmoji?: Function; onLinkPress?: Function; textStyle?: StyleProp; } diff --git a/app/containers/markdown/index.tsx b/app/containers/markdown/index.tsx index ba20bbffeaa..46d9118d7e3 100644 --- a/app/containers/markdown/index.tsx +++ b/app/containers/markdown/index.tsx @@ -5,7 +5,6 @@ import type { Root } from '@rocket.chat/message-parser'; import isEmpty from 'lodash/isEmpty'; import { type IUserMention, type IUserChannel, type TOnLinkPress } from './interfaces'; -import { type TGetCustomEmoji } from '../../definitions/IEmoji'; import MarkdownContext from './contexts/MarkdownContext'; import LineBreak from './components/LineBreak'; import { KaTeX } from './components/Katex'; @@ -26,7 +25,6 @@ interface IMarkdownProps { msg?: string | null; md?: Root; mentions?: IUserMention[]; - getCustomEmoji?: TGetCustomEmoji; username?: string; useRealName?: boolean; channels?: IUserChannel[]; @@ -109,7 +107,6 @@ const Markdown: FC = ({ navToRoomInfo, useRealName, username = '', - getCustomEmoji, onLinkPress, isTranslated, textStyle @@ -133,7 +130,6 @@ const Markdown: FC = ({ useRealName, username, navToRoomInfo, - getCustomEmoji, onLinkPress, textStyle }; diff --git a/app/containers/message/Components/Attachments/AttachedActions.tsx b/app/containers/message/Components/Attachments/AttachedActions.tsx index fdb804af534..3faea7c5e6f 100644 --- a/app/containers/message/Components/Attachments/AttachedActions.tsx +++ b/app/containers/message/Components/Attachments/AttachedActions.tsx @@ -2,7 +2,7 @@ import { useContext } from 'react'; import Button from '../../../Button'; import MessageContext from '../../Context'; -import { type IAttachment, type TGetCustomEmoji } from '../../../../definitions'; +import { type IAttachment } from '../../../../definitions'; import openLink from '../../../../lib/methods/helpers/openLink'; import Markdown from '../../../markdown'; @@ -13,7 +13,7 @@ export type TElement = { text: string; }; -const AttachedActions = ({ attachment, getCustomEmoji }: { attachment: IAttachment; getCustomEmoji: TGetCustomEmoji }) => { +const AttachedActions = ({ attachment }: { attachment: IAttachment }) => { 'use memo'; const { onAnswerButtonPress } = useContext(MessageContext); @@ -41,7 +41,7 @@ const AttachedActions = ({ attachment, getCustomEmoji }: { attachment: IAttachme }); return ( <> - + {attachedButtons} ); diff --git a/app/containers/message/Components/Attachments/Attachments.stories.tsx b/app/containers/message/Components/Attachments/Attachments.stories.tsx index 43947a2a374..31206364f05 100644 --- a/app/containers/message/Components/Attachments/Attachments.stories.tsx +++ b/app/containers/message/Components/Attachments/Attachments.stories.tsx @@ -54,7 +54,7 @@ export const SingleImageOldServer = () => ( - null} timeFormat='LT' /> + @@ -65,7 +65,7 @@ export const SingleImageNewServer = () => ( - null} timeFormat='LT' /> + @@ -76,7 +76,7 @@ export const SingleImageNoAlt = () => ( - null} timeFormat='LT' /> + @@ -87,7 +87,7 @@ export const MultipleImagesNewServer = () => ( - null} timeFormat='LT' /> + @@ -98,7 +98,7 @@ export const MultipleImagesOldServer = () => ( - null} timeFormat='LT' /> + diff --git a/app/containers/message/Components/Attachments/Attachments.tsx b/app/containers/message/Components/Attachments/Attachments.tsx index 329c0e48eec..68b2c173535 100644 --- a/app/containers/message/Components/Attachments/Attachments.tsx +++ b/app/containers/message/Components/Attachments/Attachments.tsx @@ -14,7 +14,7 @@ import { getMessageFromAttachment } from '../../utils'; import { isContentAttachment } from './utils'; const Attachments: FC = memo( - ({ attachments, timeFormat, showAttachment, getCustomEmoji, author }: IMessageAttachments) => { + ({ attachments, timeFormat, showAttachment, author }: IMessageAttachments) => { 'use memo'; const { translateLanguage } = useContext(MessageContext); @@ -34,7 +34,6 @@ const Attachments: FC = memo( key={file.image_url} file={file} showAttachment={showAttachment} - getCustomEmoji={getCustomEmoji} author={author} msg={msg} imagePreview={file.image_preview} @@ -44,30 +43,15 @@ const Attachments: FC = memo( } if (file.audio_url) { - return ); diff --git a/app/containers/message/Components/Attachments/CollapsibleQuote/CollapsibleQuote.test.tsx b/app/containers/message/Components/Attachments/CollapsibleQuote/CollapsibleQuote.test.tsx index b86d3135cc6..651c59c02fa 100644 --- a/app/containers/message/Components/Attachments/CollapsibleQuote/CollapsibleQuote.test.tsx +++ b/app/containers/message/Components/Attachments/CollapsibleQuote/CollapsibleQuote.test.tsx @@ -21,8 +21,6 @@ const testAttachment = { collapsed: true }; -const mockFn = jest.fn(); - const initialMockedStoreState = () => { mockedStore.dispatch( setUser({ @@ -44,7 +42,7 @@ const Render = () => ( onLongPress: () => {}, user: { username: 'Marcos' } }}> - + ); diff --git a/app/containers/message/Components/Attachments/CollapsibleQuote/index.tsx b/app/containers/message/Components/Attachments/CollapsibleQuote/index.tsx index 202c0a32b5b..0b46a1cbf92 100644 --- a/app/containers/message/Components/Attachments/CollapsibleQuote/index.tsx +++ b/app/containers/message/Components/Attachments/CollapsibleQuote/index.tsx @@ -5,7 +5,6 @@ import { StyleSheet, Text, View } from 'react-native'; import { themes } from '../../../../../lib/constants/colors'; import { type IAttachment } from '../../../../../definitions/IAttachment'; -import { type TGetCustomEmoji } from '../../../../../definitions/IEmoji'; import { CustomIcon } from '../../../../CustomIcon'; import { useTheme } from '../../../../../theme'; import sharedStyles from '../../../../../views/Styles'; @@ -69,22 +68,19 @@ const styles = StyleSheet.create({ interface IMessageAttText { text?: string; - getCustomEmoji: TGetCustomEmoji; } interface IMessageFields { attachment: IAttachment; - getCustomEmoji: TGetCustomEmoji; } interface IMessageReply { attachment: IAttachment; timeFormat?: string; - getCustomEmoji: TGetCustomEmoji; } const AttText = memo( - ({ text, getCustomEmoji }: IMessageAttText) => { + ({ text }: IMessageAttText) => { 'use memo'; const { user } = useContext(MessageContext); @@ -93,13 +89,13 @@ const AttText = memo( return null; } - return ; + return ; }, (prevProps, nextProps) => prevProps.text === nextProps.text ); const Fields = memo( - ({ attachment, getCustomEmoji }: IMessageFields) => { + ({ attachment }: IMessageFields) => { 'use memo'; const { theme } = useTheme(); @@ -116,7 +112,7 @@ const Fields = memo( {field.title} - + ))} @@ -126,7 +122,7 @@ const Fields = memo( ); const CollapsibleQuote = memo( - ({ attachment, getCustomEmoji }: IMessageReply) => { + ({ attachment }: IMessageReply) => { 'use memo'; const { theme } = useTheme(); @@ -177,8 +173,8 @@ const CollapsibleQuote = memo( {attachment.title} - {!collapsed && } - {!collapsed && } + {!collapsed && } + {!collapsed && } diff --git a/app/containers/message/Components/Attachments/Image/Container.tsx b/app/containers/message/Components/Attachments/Image/Container.tsx index bd288bcc046..cd2c78f219a 100644 --- a/app/containers/message/Components/Attachments/Image/Container.tsx +++ b/app/containers/message/Components/Attachments/Image/Container.tsx @@ -12,15 +12,7 @@ import { WidthAwareView } from '../../WidthAwareView'; import { useAltTextSupported } from '../../../../../lib/hooks/useAltTextSupported'; import I18n from '../../../../../i18n'; -const ImageContainer = ({ - file, - showAttachment, - getCustomEmoji, - author, - msg, - imagePreview, - imageType -}: IImageContainer): ReactElement | null => { +const ImageContainer = ({ file, showAttachment, author, msg, imagePreview, imageType }: IImageContainer): ReactElement | null => { 'use memo'; const { user } = useContext(MessageContext); @@ -52,7 +44,7 @@ const ImageContainer = ({ if (msg) { return ( - + {image} ); diff --git a/app/containers/message/Components/Attachments/Image/definitions.ts b/app/containers/message/Components/Attachments/Image/definitions.ts index 34fdaaca3a2..5ca4662a95b 100644 --- a/app/containers/message/Components/Attachments/Image/definitions.ts +++ b/app/containers/message/Components/Attachments/Image/definitions.ts @@ -1,11 +1,9 @@ import { type IAttachment, type IUserMessage } from '../../../../../definitions'; -import { type TGetCustomEmoji } from '../../../../../definitions/IEmoji'; import { type TDownloadState } from '../../../../../lib/methods/handleMediaDownload'; export interface IImageContainer { file: IAttachment; showAttachment?: (file: IAttachment) => void; - getCustomEmoji?: TGetCustomEmoji; author?: IUserMessage; msg?: string; imagePreview?: string; diff --git a/app/containers/message/Components/Attachments/Quote.tsx b/app/containers/message/Components/Attachments/Quote.tsx index 5d45a1e034b..eae787177cb 100644 --- a/app/containers/message/Components/Attachments/Quote.tsx +++ b/app/containers/message/Components/Attachments/Quote.tsx @@ -10,7 +10,7 @@ import { getMessageFromAttachment } from '../../utils'; import { isQuoteAttachment } from './utils'; const Quote: FC = memo( - ({ attachments, timeFormat, showAttachment, getCustomEmoji }: IMessageAttachments) => { + ({ attachments, timeFormat, showAttachment }: IMessageAttachments) => { 'use memo'; const { translateLanguage } = useContext(MessageContext); @@ -24,16 +24,7 @@ const Quote: FC = memo( const quotesElements = quotes.map((file: IAttachment, index: number) => { const msg = getMessageFromAttachment(file, translateLanguage); - return ( - - ); + return ; }); return {quotesElements}; diff --git a/app/containers/message/Components/Attachments/Reply.tsx b/app/containers/message/Components/Attachments/Reply.tsx index da15a41b9dd..5bb9cd5f494 100644 --- a/app/containers/message/Components/Attachments/Reply.tsx +++ b/app/containers/message/Components/Attachments/Reply.tsx @@ -3,7 +3,7 @@ import { useContext, useState, memo } from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { Image } from 'expo-image'; -import { type IAttachment, type TGetCustomEmoji } from '../../../../definitions'; +import { type IAttachment } from '../../../../definitions'; import { themes } from '../../../../lib/constants/colors'; import { fileDownloadAndPreview } from '../../../../lib/methods/helpers'; import { formatAttachmentUrl } from '../../../../lib/methods/helpers/formatAttachmentUrl'; @@ -95,7 +95,6 @@ const styles = StyleSheet.create({ interface IMessageReply { attachment: IAttachment; timeFormat?: string; - getCustomEmoji: TGetCustomEmoji; msg?: string; showAttachment?: (file: IAttachment) => void; } @@ -120,7 +119,7 @@ const Title = memo( ); const Description = memo( - ({ attachment, getCustomEmoji }: { attachment: IAttachment; getCustomEmoji: TGetCustomEmoji }) => { + ({ attachment }: { attachment: IAttachment }) => { 'use memo'; const { user } = useContext(MessageContext); @@ -140,7 +139,7 @@ const Description = memo( return ; } - return ; + return ; }, (prevProps, nextProps) => { if (prevProps.attachment.text !== nextProps.attachment.text) { @@ -173,15 +172,7 @@ const UrlImage = memo( ); const Fields = memo( - ({ - attachment, - theme, - getCustomEmoji - }: { - attachment: IAttachment; - theme: TSupportedThemes; - getCustomEmoji: TGetCustomEmoji; - }) => { + ({ attachment, theme }: { attachment: IAttachment; theme: TSupportedThemes }) => { 'use memo'; const { user } = useContext(MessageContext); @@ -195,7 +186,7 @@ const Fields = memo( {attachment.fields.map(field => ( {field.title} - + ))} @@ -206,7 +197,7 @@ const Fields = memo( ); const Reply = memo( - ({ attachment, timeFormat, getCustomEmoji, msg, showAttachment }: IMessageReply) => { + ({ attachment, timeFormat, msg, showAttachment }: IMessageReply) => { 'use memo'; const [loading, setLoading] = useState(false); @@ -252,20 +243,10 @@ const Reply = memo( - <Description attachment={attachment} getCustomEmoji={getCustomEmoji} /> - <Quote - attachments={attachment.attachments} - getCustomEmoji={getCustomEmoji} - timeFormat={timeFormat} - showAttachment={showAttachment} - /> - <Attachments - attachments={attachment.attachments} - getCustomEmoji={getCustomEmoji} - timeFormat={timeFormat} - showAttachment={showAttachment} - /> - <Fields attachment={attachment} getCustomEmoji={getCustomEmoji} theme={theme} /> + <Description attachment={attachment} /> + <Quote attachments={attachment.attachments} timeFormat={timeFormat} showAttachment={showAttachment} /> + <Attachments attachments={attachment.attachments} timeFormat={timeFormat} showAttachment={showAttachment} /> + <Fields attachment={attachment} theme={theme} /> {loading ? ( <View style={styles.backdrop}> <View @@ -280,7 +261,7 @@ const Reply = memo( <UrlImage image={attachment.thumb_url} /> </View> </Touchable> - {msg ? <Markdown msg={msg} username={user.username} getCustomEmoji={getCustomEmoji} /> : null} + {msg ? <Markdown msg={msg} username={user.username} /> : null} </View> ); }, diff --git a/app/containers/message/Components/Attachments/Video.tsx b/app/containers/message/Components/Attachments/Video.tsx index 7d9c90054ad..6f6c2e5ba2e 100644 --- a/app/containers/message/Components/Attachments/Video.tsx +++ b/app/containers/message/Components/Attachments/Video.tsx @@ -3,7 +3,6 @@ import { StyleSheet, Text, View } from 'react-native'; import { type IUserMessage } from '../../../../definitions'; import { type IAttachment } from '../../../../definitions/IAttachment'; -import { type TGetCustomEmoji } from '../../../../definitions/IEmoji'; import I18n from '../../../../i18n'; import { fileDownload, isIOS } from '../../../../lib/methods/helpers'; import EventEmitter from '../../../../lib/methods/helpers/events'; @@ -37,7 +36,6 @@ const styles = StyleSheet.create({ interface IMessageVideo { file: IAttachment; showAttachment?: (file: IAttachment) => void; - getCustomEmoji: TGetCustomEmoji; author?: IUserMessage; msg?: string; } @@ -70,7 +68,7 @@ const Thumbnail = ({ status, encrypted = false }: { status: TDownloadState; encr ); }; -const Video = ({ file, showAttachment, getCustomEmoji, author, msg }: IMessageVideo): ReactElement | null => { +const Video = ({ file, showAttachment, author, msg }: IMessageVideo): ReactElement | null => { 'use memo'; const { user } = useContext(MessageContext); @@ -101,7 +99,7 @@ const Video = ({ file, showAttachment, getCustomEmoji, author, msg }: IMessageVi return ( <View style={{ gap: 4 }}> - {msg ? <Markdown msg={msg} username={user.username} getCustomEmoji={getCustomEmoji} /> : null} + {msg ? <Markdown msg={msg} username={user.username} /> : null} <Touchable onPress={_onPress} style={messageStyles.image}> <Thumbnail status={status} encrypted={isEncrypted} /> </Touchable> diff --git a/app/containers/message/Content.test.tsx b/app/containers/message/Content.test.tsx index 3013e84f872..d9175bee6f2 100644 --- a/app/containers/message/Content.test.tsx +++ b/app/containers/message/Content.test.tsx @@ -28,7 +28,6 @@ const baseProps: Partial<IMessageContent> = { isTranslated: false, isHeader: false, hasError: false, - getCustomEmoji: jest.fn(), navToRoomInfo: jest.fn() }; diff --git a/app/containers/message/Content.tsx b/app/containers/message/Content.tsx index c6f132ff7be..8e6ce6387be 100644 --- a/app/containers/message/Content.tsx +++ b/app/containers/message/Content.tsx @@ -64,7 +64,6 @@ const Content = memo( <Markdown msg={props.msg} md={props.type !== 'e2e' ? props.md : undefined} - getCustomEmoji={props.getCustomEmoji} username={user.username} channels={props.channels} mentions={props.mentions} diff --git a/app/containers/message/Emoji.tsx b/app/containers/message/Emoji.tsx index 0540a7c86ef..68e880b39ec 100644 --- a/app/containers/message/Emoji.tsx +++ b/app/containers/message/Emoji.tsx @@ -2,13 +2,15 @@ import { memo } from 'react'; import { Text } from 'react-native'; import useShortnameToUnicode from '../../lib/hooks/useShortnameToUnicode'; +import { useCustomEmoji } from '../../lib/hooks/useCustomEmoji'; import CustomEmoji from '../EmojiPicker/CustomEmoji'; import { type IMessageEmoji } from './interfaces'; const Emoji = memo( - ({ content, standardEmojiStyle, customEmojiStyle, getCustomEmoji }: IMessageEmoji) => { + ({ content, standardEmojiStyle, customEmojiStyle }: IMessageEmoji) => { 'use memo'; + const getCustomEmoji = useCustomEmoji(); const parsedContent = content.replace(/^:|:$/g, ''); const emoji = getCustomEmoji(parsedContent); const { formatShortnameToUnicode } = useShortnameToUnicode(); diff --git a/app/containers/message/Message.stories.tsx b/app/containers/message/Message.stories.tsx index 0320d52459f..bca767224db 100644 --- a/app/containers/message/Message.stories.tsx +++ b/app/containers/message/Message.stories.tsx @@ -14,6 +14,7 @@ import { } from '../../lib/hooks/useResponsiveLayout/useResponsiveLayout'; import { mockedStore as store } from '../../reducers/mockedStore'; import { updateSettings } from '../../actions/settings'; +import { setCustomEmojis } from '../../actions/customEmojis'; const _theme = 'light'; @@ -51,6 +52,13 @@ const longText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; store.dispatch(updateSettings('API_Embed', true)); +store.dispatch( + setCustomEmojis({ + marioparty: { name: 'marioparty', extension: 'gif' }, + react_rocket: { name: 'react_rocket', extension: 'png' }, + nyan_rocket: { name: 'nyan_rocket', extension: 'png' } + }) +); const responsiveLayoutProviderLargeFontValue = (fontScale: number) => ({ fontScale, @@ -62,15 +70,6 @@ const responsiveLayoutProviderLargeFontValue = (fontScale: number) => ({ height: 800 }); -const getCustomEmoji = (content: string) => { - const customEmoji = { - marioparty: { name: content, extension: 'gif' }, - react_rocket: { name: content, extension: 'png' }, - nyan_rocket: { name: content, extension: 'png' } - }[content]; - return customEmoji; -}; - export default { title: 'Message', decorators: [ @@ -93,7 +92,6 @@ export const Message = (props: any) => ( ts={date} timeFormat='LT' isHeader - getCustomEmoji={getCustomEmoji} theme={_theme} {...props} /> @@ -110,7 +108,6 @@ const MessageLargeFont = (props: any) => ( ts={date} timeFormat='LT' isHeader - getCustomEmoji={getCustomEmoji} theme={_theme} {...props} /> diff --git a/app/containers/message/MessageAvatar.tsx b/app/containers/message/MessageAvatar.tsx index 3727b2c4729..95a824197ae 100644 --- a/app/containers/message/MessageAvatar.tsx +++ b/app/containers/message/MessageAvatar.tsx @@ -16,7 +16,7 @@ export const AvatarContainer = ({ children }: { children?: ReactElement | null } return <View style={{ width, alignItems: 'flex-end' }}>{children}</View>; }; -const MessageAvatar = memo(({ isHeader, avatar, author, small, navToRoomInfo, emoji, getCustomEmoji }: IMessageAvatar) => { +const MessageAvatar = memo(({ isHeader, avatar, author, small, navToRoomInfo, emoji }: IMessageAvatar) => { 'use memo'; const { user } = useContext(MessageContext); @@ -41,7 +41,6 @@ const MessageAvatar = memo(({ isHeader, avatar, author, small, navToRoomInfo, em size={size} borderRadius={4} onPress={onPress} - getCustomEmoji={getCustomEmoji} avatar={avatar} emoji={emoji} /> diff --git a/app/containers/message/Preview.tsx b/app/containers/message/Preview.tsx index c8705b32fab..5bcd6045994 100644 --- a/app/containers/message/Preview.tsx +++ b/app/containers/message/Preview.tsx @@ -1,30 +1,24 @@ import Message from './index'; import { useAppSelector } from '../../lib/hooks/useAppSelector'; import { getUserSelector } from '../../selectors/login'; -import { type TAnyMessageModel, type TGetCustomEmoji } from '../../definitions'; +import { type TAnyMessageModel } from '../../definitions'; const MessagePreview = ({ message }: { message: TAnyMessageModel }) => { 'use memo'; - const { user, baseUrl, Message_TimeFormat, customEmojis, useRealName } = useAppSelector(state => ({ + const { user, baseUrl, Message_TimeFormat, useRealName } = useAppSelector(state => ({ user: getUserSelector(state), baseUrl: state.server.server, Message_TimeFormat: state.settings.Message_TimeFormat as string, - customEmojis: state.customEmojis, useRealName: state.settings.UI_Use_Real_Name as boolean })); - const getCustomEmoji: TGetCustomEmoji = name => { - const emoji = customEmojis[name]; - return emoji ?? null; - }; return ( <Message item={message} user={user} rid={message.rid} baseUrl={baseUrl} - getCustomEmoji={getCustomEmoji} timeFormat={Message_TimeFormat} useRealName={useRealName} isPreview diff --git a/app/containers/message/Reactions.test.tsx b/app/containers/message/Reactions.test.tsx index 05d1fe8b081..5adeeaf39c3 100644 --- a/app/containers/message/Reactions.test.tsx +++ b/app/containers/message/Reactions.test.tsx @@ -37,14 +37,12 @@ const TestWrapper = ({ initialReactions }: { initialReactions: IReaction[] }) => onReactionPress: handleReactionPress, onReactionLongPress: jest.fn() }}> - <Reactions reactions={reactions} getCustomEmoji={getCustomEmoji} /> + <Reactions reactions={reactions} /> </MessageContext.Provider> </Provider> ); }; -const getCustomEmoji = jest.fn(); - it('renders all reactions and AddReaction button', () => { const reactions: IReaction[] = [ { _id: '1', emoji: '👍', usernames: ['john', 'alice'], names: [] }, diff --git a/app/containers/message/Reactions.tsx b/app/containers/message/Reactions.tsx index aaadbe5b369..08013aabb49 100644 --- a/app/containers/message/Reactions.tsx +++ b/app/containers/message/Reactions.tsx @@ -10,7 +10,6 @@ import { BUTTON_HIT_SLOP } from './utils'; import { themes } from '../../lib/constants/colors'; import { type TSupportedThemes, useTheme } from '../../theme'; import MessageContext from './Context'; -import { type TGetCustomEmoji } from '../../definitions/IEmoji'; interface IReaction { _id: string; @@ -20,13 +19,11 @@ interface IReaction { interface IMessageReaction { reaction: IReaction; - getCustomEmoji: TGetCustomEmoji; theme: TSupportedThemes; } interface IMessageReactions { reactions?: IReaction[]; - getCustomEmoji: TGetCustomEmoji; } const AddReaction = memo(({ theme }: { theme: TSupportedThemes }) => { @@ -52,7 +49,7 @@ const AddReaction = memo(({ theme }: { theme: TSupportedThemes }) => { ); }); -const Reaction = memo(({ reaction, getCustomEmoji, theme }: IMessageReaction) => { +const Reaction = memo(({ reaction, theme }: IMessageReaction) => { 'use memo'; const { onReactionPress, onReactionLongPress, user } = useContext(MessageContext); @@ -76,19 +73,14 @@ const Reaction = memo(({ reaction, getCustomEmoji, theme }: IMessageReaction) => styles.reactionContainer, { borderColor: reacted ? themes[theme].badgeBackgroundLevel2 : themes[theme].strokeLight, height } ]}> - <Emoji - content={reaction.emoji} - standardEmojiStyle={styles.reactionEmoji} - customEmojiStyle={styles.reactionCustomEmoji} - getCustomEmoji={getCustomEmoji} - /> + <Emoji content={reaction.emoji} standardEmojiStyle={styles.reactionEmoji} customEmojiStyle={styles.reactionCustomEmoji} /> <Text style={[styles.reactionCount, { color: themes[theme].badgeBackgroundLevel2 }]}>{reaction.usernames.length}</Text> </View> </Touchable> ); }); -const Reactions = memo(({ reactions, getCustomEmoji }: IMessageReactions) => { +const Reactions = memo(({ reactions }: IMessageReactions) => { 'use memo'; const { theme } = useTheme(); @@ -99,7 +91,7 @@ const Reactions = memo(({ reactions, getCustomEmoji }: IMessageReactions) => { return ( <View style={styles.reactionsContainer}> {reactions.map(reaction => ( - <Reaction key={reaction.emoji} reaction={reaction} getCustomEmoji={getCustomEmoji} theme={theme} /> + <Reaction key={reaction.emoji} reaction={reaction} theme={theme} /> ))} <AddReaction theme={theme} /> </View> diff --git a/app/containers/message/index.tsx b/app/containers/message/index.tsx index df0e3ee8a57..9f99526dfcb 100644 --- a/app/containers/message/index.tsx +++ b/app/containers/message/index.tsx @@ -7,7 +7,7 @@ import { debounce } from '../../lib/methods/helpers'; import { getMessageTranslation } from './utils'; import { type TSupportedThemes, withTheme } from '../../theme'; import openLink from '../../lib/methods/helpers/openLink'; -import { type IAttachment, type TAnyMessageModel, type TGetCustomEmoji } from '../../definitions'; +import { type IAttachment, type TAnyMessageModel } from '../../definitions'; import { type IRoomInfoParam } from '../../views/SearchMessagesView'; import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../../lib/constants/keys'; import { messagesStatus } from '../../lib/constants/messagesStatus'; @@ -37,7 +37,6 @@ interface IMessageContainerProps { status?: number; isIgnored?: boolean; highlighted?: boolean; - getCustomEmoji: TGetCustomEmoji; onLongPress?: (item: TAnyMessageModel) => void; onReactionPress?: (emoji: string, id: string) => void; onEncryptedPress?: () => void; @@ -71,7 +70,6 @@ interface IMessageContainerState { class MessageContainer extends Component<IMessageContainerProps, IMessageContainerState> { static defaultProps = { - getCustomEmoji: () => null, onLongPress: () => {}, blockAction: () => {}, archived: false, @@ -367,7 +365,6 @@ class MessageContainer extends Component<IMessageContainerProps, IMessageContain autoTranslateRoom, autoTranslateLanguage, navToRoomInfo = () => {}, - getCustomEmoji, isThreadRoom, handleEnterCall, blockAction, @@ -496,7 +493,6 @@ class MessageContainer extends Component<IMessageContainerProps, IMessageContain isEncrypted={this.isEncrypted} hasError={this.hasError} showAttachment={showAttachment} - getCustomEmoji={getCustomEmoji} navToRoomInfo={navToRoomInfo} handleEnterCall={handleEnterCall} blockAction={blockAction} diff --git a/app/containers/message/interfaces.ts b/app/containers/message/interfaces.ts index 6e33a9583bb..4800bee0a17 100644 --- a/app/containers/message/interfaces.ts +++ b/app/containers/message/interfaces.ts @@ -3,9 +3,9 @@ import { type StyleProp } from 'react-native'; import { type ImageStyle } from 'expo-image'; import { type IUserChannel } from '../markdown/interfaces'; -import { type TGetCustomEmoji } from '../../definitions/IEmoji'; import { type IAttachment, + type IReaction, type IThread, type IUrl, type IUserMention, @@ -19,7 +19,6 @@ export interface IMessageAttachments { attachments?: IAttachment[]; timeFormat?: string; showAttachment?: (file: IAttachment) => void; - getCustomEmoji: TGetCustomEmoji; author?: IUserMessage; } @@ -30,7 +29,6 @@ export interface IMessageAvatar { author?: IUserMessage; small?: boolean; navToRoomInfo: (navParam: IRoomInfoParam) => void; - getCustomEmoji: TGetCustomEmoji; } export interface IMessageBlocks { @@ -59,7 +57,6 @@ export interface IMessageContent { md?: Root; isEdited: boolean; isEncrypted: boolean; - getCustomEmoji: TGetCustomEmoji; channels?: IUserChannel[]; mentions?: IUserMention[]; navToRoomInfo: (navParam: IRoomInfoParam) => void; @@ -79,7 +76,6 @@ export interface IMessageEmoji { content: string; standardEmojiStyle: { fontSize: number }; customEmojiStyle: StyleProp<ImageStyle>; - getCustomEmoji: TGetCustomEmoji; } export interface IMessageThread extends Pick<IThread, 'msg' | 'tcount' | 'tlm' | 'id'> { @@ -119,6 +115,7 @@ export interface IMessageInner blocks: []; urls?: IUrl[]; isPreview?: boolean; + reactions?: IReaction[]; } export interface IMessage extends IMessageRepliedThread, IMessageInner, IMessageAvatar { diff --git a/app/lib/hooks/useCustomEmoji.test.ts b/app/lib/hooks/useCustomEmoji.test.ts new file mode 100644 index 00000000000..ff938f57b3b --- /dev/null +++ b/app/lib/hooks/useCustomEmoji.test.ts @@ -0,0 +1,28 @@ +import { renderHook } from '@testing-library/react-native'; + +import { resolveCustomEmoji, useCustomEmoji } from './useCustomEmoji'; + +const customEmojis = { nyan_rocket: { name: 'nyan_rocket', extension: 'png' } }; + +jest.mock('./useAppSelector', () => ({ + useAppSelector: (selector: (state: any) => any) => selector({ customEmojis }) +})); + +describe('resolveCustomEmoji', () => { + it('returns the emoji when the name is registered', () => { + expect(resolveCustomEmoji(customEmojis, 'nyan_rocket')).toBe(customEmojis.nyan_rocket); + }); + + it('returns null when the name is not registered', () => { + expect(resolveCustomEmoji(customEmojis, 'unknown')).toBeNull(); + }); +}); + +describe('useCustomEmoji', () => { + it('returns a getter resolving against state.customEmojis', () => { + const { result } = renderHook(() => useCustomEmoji()); + + expect(result.current('nyan_rocket')).toBe(customEmojis.nyan_rocket); + expect(result.current('unknown')).toBeNull(); + }); +}); diff --git a/app/lib/hooks/useCustomEmoji.ts b/app/lib/hooks/useCustomEmoji.ts new file mode 100644 index 00000000000..65ac1402495 --- /dev/null +++ b/app/lib/hooks/useCustomEmoji.ts @@ -0,0 +1,11 @@ +import { type ICustomEmojis, type TGetCustomEmoji } from '../../definitions'; +import { useAppSelector } from './useAppSelector'; + +export const resolveCustomEmoji = (customEmojis: ICustomEmojis, name: string) => customEmojis[name] ?? null; + +export const useCustomEmoji = (): TGetCustomEmoji => { + 'use memo'; + + const customEmojis = useAppSelector(state => state.customEmojis); + return name => resolveCustomEmoji(customEmojis, name); +}; diff --git a/app/views/MessagesView/index.tsx b/app/views/MessagesView/index.tsx index 442bf5b41de..a9ca795be42 100644 --- a/app/views/MessagesView/index.tsx +++ b/app/views/MessagesView/index.tsx @@ -28,9 +28,7 @@ import { type IAttachment, type IMessage, type TAnyMessageModel, - type IUrl, - type TGetCustomEmoji, - type ICustomEmoji + type IUrl } from '../../definitions'; import { getFiles, getMessages, getPinnedMessages, togglePinMessage, toggleStarMessage } from '../../lib/services/restApi'; import { type TNavigation } from '../../stacks/stackType'; @@ -51,7 +49,6 @@ interface IMessagesViewProps { NativeStackNavigationProp<MasterDetailInsideStackParamList & TNavigation> >; route: RouteProp<ChatsStackParamList, 'MessagesView'>; - customEmojis: { [key: string]: ICustomEmoji }; theme: TSupportedThemes; showActionSheet: (params: { options: string[]; hasCancel: boolean }) => void; useRealName: boolean; @@ -176,7 +173,6 @@ class MessagesView extends Component<IMessagesViewProps, IMessagesViewState> { attachments: item.attachments || [], useRealName, showAttachment: this.showAttachment, - getCustomEmoji: this.getCustomEmoji, navToRoomInfo: this.navToRoomInfo, onPress: () => this.jumpToMessage({ item }), rid: this.rid @@ -303,15 +299,6 @@ class MessagesView extends Component<IMessagesViewProps, IMessagesViewState> { } }; - getCustomEmoji: TGetCustomEmoji = name => { - const { customEmojis } = this.props; - const emoji = customEmojis[name]; - if (emoji) { - return emoji; - } - return null; - }; - showAttachment = (attachment: IAttachment) => { const { navigation } = this.props; navigation.navigate('AttachmentView', { attachment }); @@ -385,7 +372,6 @@ class MessagesView extends Component<IMessagesViewProps, IMessagesViewState> { const mapStateToProps = (state: IApplicationState) => ({ baseUrl: state.server.server, user: getUserSelector(state), - customEmojis: state.customEmojis, useRealName: state.settings.UI_Use_Real_Name }); diff --git a/app/views/RoomView/definitions.ts b/app/views/RoomView/definitions.ts index e583db6a387..5bce9a25709 100644 --- a/app/views/RoomView/definitions.ts +++ b/app/views/RoomView/definitions.ts @@ -6,7 +6,6 @@ import { type ILastMessage, type ILoggedUser, type TSubscriptionModel, - type ICustomEmojis, type TMessageAction } from '../../definitions'; import { type IActionSheetProvider } from '../../containers/ActionSheet'; @@ -21,7 +20,6 @@ export interface IRoomViewProps extends IActionSheetProvider, IBaseScreen<ChatsS Hide_System_Messages?: string[]; baseUrl: string; serverVersion: string | null; - customEmojis: ICustomEmojis; isMasterDetail: boolean; replyBroadcast: Function; width: number; diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index f01b818c42c..2a1527a4822 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -70,7 +70,6 @@ import { type TAnyMessageModel, type TSubscriptionModel, type IEmoji, - type TGetCustomEmoji, type RoomType } from '../../definitions'; import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../../lib/constants/keys'; @@ -932,7 +931,7 @@ class RoomView extends Component<IRoomViewProps, IRoomViewState> { onReactionLongPress = (message: TAnyMessageModel) => { const { showActionSheet } = this.props; this.handleCloseEmoji(showActionSheet, { - children: <ReactionsList reactions={message?.reactions} getCustomEmoji={this.getCustomEmoji} />, + children: <ReactionsList reactions={message?.reactions} />, snaps: ['50%'], enableContentPanningGesture: false, fullContainer: true @@ -1129,15 +1128,6 @@ class RoomView extends Component<IRoomViewProps, IRoomViewState> { this.resetAction(); }; - getCustomEmoji: TGetCustomEmoji = name => { - const { customEmojis } = this.props; - const emoji = customEmojis[name]; - if (emoji) { - return emoji; - } - return null; - }; - setLastOpen = (lastOpen: Date | null) => this.setState({ lastOpen }); onJoin = () => { @@ -1505,7 +1495,6 @@ class RoomView extends Component<IRoomViewProps, IRoomViewState> { autoTranslateRoom={canAutoTranslate && 'id' in room && room.autoTranslate} autoTranslateLanguage={'id' in room ? room.autoTranslateLanguage : undefined} navToRoomInfo={this.navToRoomInfo} - getCustomEmoji={this.getCustomEmoji} handleEnterCall={this.handleEnterCall} blockAction={this.blockAction} threadBadgeColor={this.getBadgeColor(item?.id)} @@ -1741,7 +1730,6 @@ const mapStateToProps = (state: IApplicationState) => ({ isAuthenticated: state.login.isAuthenticated, Message_GroupingPeriod: state.settings.Message_GroupingPeriod as number, Message_TimeFormat: state.settings.Message_TimeFormat as string, - customEmojis: state.customEmojis, baseUrl: state.server.server, serverVersion: state.server.version, Message_Read_Receipt_Enabled: state.settings.Message_Read_Receipt_Enabled as boolean, diff --git a/app/views/SearchMessagesView/index.tsx b/app/views/SearchMessagesView/index.tsx index 4f58b84e1df..c637a689634 100644 --- a/app/views/SearchMessagesView/index.tsx +++ b/app/views/SearchMessagesView/index.tsx @@ -36,9 +36,7 @@ import { type IAttachment, type ISubscription, SubscriptionType, - type TSubscriptionModel, - type TGetCustomEmoji, - type ICustomEmoji + type TSubscriptionModel } from '../../definitions'; import { searchMessages } from '../../lib/services/restApi'; import { type TNavigation } from '../../stacks/stackType'; @@ -74,9 +72,6 @@ interface ISearchMessagesViewProps extends INavigationOption { user: IUser; baseUrl: string; serverVersion: string; - customEmojis: { - [key: string]: ICustomEmoji; - }; theme: TSupportedThemes; useRealName: boolean; isMasterDetail: boolean; @@ -210,15 +205,6 @@ class SearchMessagesView extends Component<ISearchMessagesViewProps, ISearchMess await this.getMessages(searchText, true); }, textInputDebounceTime); - getCustomEmoji: TGetCustomEmoji = name => { - const { customEmojis } = this.props; - const emoji = customEmojis[name]; - if (emoji) { - return emoji; - } - return null; - }; - showAttachment = (attachment: IAttachment) => { const { navigation } = this.props; navigation.navigate('AttachmentView', { attachment }); @@ -297,7 +283,6 @@ class SearchMessagesView extends Component<ISearchMessagesViewProps, ISearchMess timeFormat='MMM Do YYYY, h:mm:ss a' isThreadRoom showAttachment={this.showAttachment} - getCustomEmoji={this.getCustomEmoji} navToRoomInfo={this.navToRoomInfo} useRealName={useRealName} theme={theme} @@ -357,8 +342,7 @@ const mapStateToProps = (state: any) => ({ serverVersion: state.server.version, baseUrl: state.server.server, user: getUserSelector(state), - useRealName: state.settings.UI_Use_Real_Name, - customEmojis: state.customEmojis + useRealName: state.settings.UI_Use_Real_Name }); export default connect(mapStateToProps)(withTheme(withMasterDetail(withSafeAreaInsets(SearchMessagesView))));