diff --git a/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx b/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx index e245d1b13..a4656fc96 100644 --- a/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx +++ b/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx @@ -37,6 +37,7 @@ import { useSendbirdChat, useUserProfile, } from '../../hooks/useContext'; +import SBUUtils from '../../libs/SBUUtils'; import ChatFlatList from '../ChatFlatList'; import { ReactionAddons } from '../ReactionAddons'; @@ -271,8 +272,11 @@ const useCreateMessagePressActions = onDeleteMessage(message), getAvailableUriFromFileMessage(message)); + handlers.onOpenFileURL?.(message.url); + } else { + const openFile = handlers.onOpenFileURL ?? SBUUtils.openURL; + openFile(message.url); } - handlers.onOpenFileURL(message.url); } }; diff --git a/packages/uikit-react-native/src/components/ChannelThreadMessageList/index.tsx b/packages/uikit-react-native/src/components/ChannelThreadMessageList/index.tsx index e5f101c51..4e1a7057f 100644 --- a/packages/uikit-react-native/src/components/ChannelThreadMessageList/index.tsx +++ b/packages/uikit-react-native/src/components/ChannelThreadMessageList/index.tsx @@ -37,6 +37,7 @@ import { useSendbirdChat, useUserProfile, } from '../../hooks/useContext'; +import SBUUtils from '../../libs/SBUUtils'; import { ReactionAddons } from '../ReactionAddons'; import ThreadChatFlatList from '../ThreadChatFlatList'; @@ -249,8 +250,11 @@ const useCreateMessagePressActions = onDeleteMessage(message), getAvailableUriFromFileMessage(message)); + handlers.onOpenFileURL?.(message.url); + } else { + const openFile = handlers.onOpenFileURL ?? SBUUtils.openURL; + openFile(message.url); } - handlers.onOpenFileURL(message.url); } }; diff --git a/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx b/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx index bc14229ad..a4325358f 100644 --- a/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx +++ b/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx @@ -219,7 +219,6 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => { const sbuHandlers: SBUHandlers = { onOpenURL: SBUUtils.openURL, - onOpenFileURL: SBUUtils.openURL, ...handlers, }; diff --git a/packages/uikit-react-native/src/contexts/SBUHandlersCtx.tsx b/packages/uikit-react-native/src/contexts/SBUHandlersCtx.tsx index cddd49a26..a5af3a682 100644 --- a/packages/uikit-react-native/src/contexts/SBUHandlersCtx.tsx +++ b/packages/uikit-react-native/src/contexts/SBUHandlersCtx.tsx @@ -14,7 +14,7 @@ export interface SBUHandlers { * Note that this function is also called redundantly * when `onPressMediaMessage` handler is triggered by clicking on media messages containing images, videos, or audio. */ - onOpenFileURL: (url: string) => void; + onOpenFileURL?: (url: string) => void; } type Props = React.PropsWithChildren; diff --git a/packages/uikit-react-native/src/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.tsx b/packages/uikit-react-native/src/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.tsx index 466641c09..c06cc3260 100644 --- a/packages/uikit-react-native/src/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.tsx +++ b/packages/uikit-react-native/src/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.tsx @@ -31,6 +31,7 @@ import ThreadParentMessageRenderer, { ThreadParentMessageRendererProps, } from '../../../components/ThreadParentMessageRenderer'; import { useLocalization, usePlatformService, useSBUHandlers, useSendbirdChat } from '../../../hooks/useContext'; +import SBUUtils from '../../../libs/SBUUtils'; import { GroupChannelThreadContexts } from '../module/moduleContext'; import type { GroupChannelThreadProps } from '../types'; import { ReactionAddons } from './../../../components/ReactionAddons'; @@ -224,9 +225,12 @@ const useCreateMessagePressActions = ({ if (message.isFileMessage()) { const fileType = getFileType(message.type || getFileExtension(message.name)); if (['image', 'video', 'audio'].includes(fileType)) { - onPressMediaMessage?.(message, () => onDeleteMessage?.(message), getAvailableUriFromFileMessage(message)); + onPressMediaMessage?.(message, () => onDeleteMessage(message), getAvailableUriFromFileMessage(message)); + handlers.onOpenFileURL?.(message.url); + } else { + const openFile = handlers.onOpenFileURL ?? SBUUtils.openURL; + openFile(message.url); } - handlers.onOpenFileURL(message.url); } }; @@ -239,7 +243,7 @@ const useCreateMessagePressActions = ({ text: STRINGS.LABELS.CHANNEL_MESSAGE_DELETE_CONFIRM_OK, style: 'destructive', onPress: () => { - onDeleteMessage?.(message).catch(onDeleteFailure); + onDeleteMessage(message).catch(onDeleteFailure); }, }, ],