From 379bcce0bb4f123108bec86e6decdfe93b3c3718 Mon Sep 17 00:00:00 2001 From: bang9 Date: Thu, 5 Oct 2023 17:33:54 +0900 Subject: [PATCH] feat: add reaction.onPressUserProfile to SendbirdUIKitContainer props --- .../ReactionUserListBottomSheet.tsx | 4 ++-- .../src/components/ReactionBottomSheets/index.tsx | 5 +++-- .../src/containers/SendbirdUIKitContainer.tsx | 12 ++++++------ .../uikit-react-native/src/contexts/ReactionCtx.tsx | 12 +++++++----- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/uikit-react-native/src/components/ReactionBottomSheets/ReactionUserListBottomSheet.tsx b/packages/uikit-react-native/src/components/ReactionBottomSheets/ReactionUserListBottomSheet.tsx index 5c3b5b352..1189b96cf 100644 --- a/packages/uikit-react-native/src/components/ReactionBottomSheets/ReactionUserListBottomSheet.tsx +++ b/packages/uikit-react-native/src/components/ReactionBottomSheets/ReactionUserListBottomSheet.tsx @@ -22,7 +22,7 @@ const ReactionUserListBottomSheet = ({ reactionCtx, chatCtx, localizationCtx, - userProfileCtx, + onPressUserProfile, }: ReactionBottomSheetProps) => { const { width } = useWindowDimensions(); const { bottom, left, right } = useSafeAreaInsets(); @@ -134,7 +134,7 @@ const ReactionUserListBottomSheet = ({ onPress={async () => { if (user) { await onClose(); - userProfileCtx.show(user); + onPressUserProfile(user); } }} style={styles.pageItem} diff --git a/packages/uikit-react-native/src/components/ReactionBottomSheets/index.tsx b/packages/uikit-react-native/src/components/ReactionBottomSheets/index.tsx index bd7abb854..207558b72 100644 --- a/packages/uikit-react-native/src/components/ReactionBottomSheets/index.tsx +++ b/packages/uikit-react-native/src/components/ReactionBottomSheets/index.tsx @@ -1,9 +1,10 @@ import type React from 'react'; +import type { SendbirdMember, SendbirdUser } from '@sendbird/uikit-utils'; + import type { LocalizationContext } from '../../contexts/LocalizationCtx'; import type { ReactionContext } from '../../contexts/ReactionCtx'; import type { SendbirdChatContext } from '../../contexts/SendbirdChatCtx'; -import type { UserProfileContext } from '../../contexts/UserProfileCtx'; import ReactionList from './ReactionListBottomSheet'; import UserList from './ReactionUserListBottomSheet'; @@ -12,10 +13,10 @@ export type ReactionBottomSheetProps = { visible: boolean; onDismiss: () => void; onClose: () => Promise; + onPressUserProfile: (user: SendbirdUser | SendbirdMember) => void; chatCtx: GetFromContext; reactionCtx: GetFromContext; localizationCtx: GetFromContext; - userProfileCtx: GetFromContext; }; export const ReactionBottomSheets = { diff --git a/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx b/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx index 7aedb0007..1fad4148b 100644 --- a/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx +++ b/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx @@ -110,6 +110,9 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{ users: SendbirdUser[] | SendbirdMember[], ) => SendbirdGroupChannelCreateParams | Promise; }; + reaction?: { + onPressUserProfile?: (user: SendbirdUser | SendbirdMember) => void; + }; userMention?: Pick, 'mentionLimit' | 'suggestionLimit' | 'debounceMills'>; imageCompression?: Partial; }>; @@ -125,6 +128,7 @@ const SendbirdUIKitContainer = ({ errorBoundary, toast, userProfile, + reaction, userMention, imageCompression, }: SendbirdUIKitContainerProps) => { @@ -232,12 +236,8 @@ const SendbirdUIKitContainer = ({ statusBarTranslucent={styles?.statusBarTranslucent ?? true} > - - + + {(value) => { const STRINGS = value?.STRINGS || defaultStringSet; diff --git a/packages/uikit-react-native/src/contexts/ReactionCtx.tsx b/packages/uikit-react-native/src/contexts/ReactionCtx.tsx index cddd84efb..ec02b6e06 100644 --- a/packages/uikit-react-native/src/contexts/ReactionCtx.tsx +++ b/packages/uikit-react-native/src/contexts/ReactionCtx.tsx @@ -3,7 +3,7 @@ import React, { useCallback, useContext, useReducer, useRef, useState } from 're import type { SendbirdBaseChannel, SendbirdBaseMessage } from '@sendbird/uikit-utils'; import { NOOP } from '@sendbird/uikit-utils'; -import { ReactionBottomSheets } from '../components/ReactionBottomSheets'; +import { ReactionBottomSheetProps, ReactionBottomSheets } from '../components/ReactionBottomSheets'; import { LocalizationContext } from '../contexts/LocalizationCtx'; import { SendbirdChatContext } from '../contexts/SendbirdChatCtx'; import { UserProfileContext } from '../contexts/UserProfileCtx'; @@ -19,10 +19,12 @@ export type ReactionContextType = { focusIndex: number; } & State; -type Props = React.PropsWithChildren<{}>; +type Props = React.PropsWithChildren<{ + onPressUserProfile?: ReactionBottomSheetProps['onPressUserProfile']; +}>; export const ReactionContext = React.createContext(null); -export const ReactionProvider = ({ children }: Props) => { +export const ReactionProvider = ({ children, onPressUserProfile }: Props) => { const chatCtx = useContext(SendbirdChatContext); const localizationCtx = useContext(LocalizationContext); const userProfileCtx = useContext(UserProfileContext); @@ -73,11 +75,11 @@ export const ReactionProvider = ({ children }: Props) => { focusIndex: reactionUserListFocusIndex, }; - const sheetProps = { + const sheetProps: Omit = { chatCtx, reactionCtx, localizationCtx, - userProfileCtx, + onPressUserProfile: onPressUserProfile ?? userProfileCtx.show, onDismiss: () => { setState({}); closeResolver.current?.();