From c4561a0c87b372cf69a53b6ecd7312ef3337ee95 Mon Sep 17 00:00:00 2001 From: bang9 Date: Mon, 28 Oct 2024 13:14:17 +0900 Subject: [PATCH 1/2] fix: resolve this binding issues --- .../src/components/ChannelInput/index.tsx | 2 +- .../components/ReactionAddons/BottomSheetReactionAddon.tsx | 5 ++++- .../ReactionBottomSheets/ReactionListBottomSheet.tsx | 6 +++++- .../src/hooks/usePushTokenRegistration.ts | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/uikit-react-native/src/components/ChannelInput/index.tsx b/packages/uikit-react-native/src/components/ChannelInput/index.tsx index 656c16ad2..b8b36c2c8 100644 --- a/packages/uikit-react-native/src/components/ChannelInput/index.tsx +++ b/packages/uikit-react-native/src/components/ChannelInput/index.tsx @@ -192,7 +192,7 @@ const useTypingTrigger = (text: string, channel: SendbirdBaseChannel) => { () => { function triggerTyping() { if (channel.isGroupChannel()) { - const action = text.length === 0 ? channel.endTyping : channel.startTyping; + const action = () => (text.length === 0 ? channel.endTyping() : channel.startTyping()); action().catch((error) => { Logger.debug('ChannelInput: Failed to trigger typing', error); }); diff --git a/packages/uikit-react-native/src/components/ReactionAddons/BottomSheetReactionAddon.tsx b/packages/uikit-react-native/src/components/ReactionAddons/BottomSheetReactionAddon.tsx index dbb7ea3cc..b7c70b680 100644 --- a/packages/uikit-react-native/src/components/ReactionAddons/BottomSheetReactionAddon.tsx +++ b/packages/uikit-react-native/src/components/ReactionAddons/BottomSheetReactionAddon.tsx @@ -47,7 +47,10 @@ const BottomSheetReactionAddon = ({ onClose, message, channel }: Props) => { const reacted = currentUserIdx > -1; const onPress = async () => { - const action = reacted ? channel.deleteReaction : channel.addReaction; + const action = (message: BaseMessage, key: string) => { + return reacted ? channel.deleteReaction(message, key) : channel.addReaction(message, key); + }; + await action(message, key) .catch((error) => { Logger.warn('Failed to reaction', error); diff --git a/packages/uikit-react-native/src/components/ReactionBottomSheets/ReactionListBottomSheet.tsx b/packages/uikit-react-native/src/components/ReactionBottomSheets/ReactionListBottomSheet.tsx index c18f90444..8cdce2d87 100644 --- a/packages/uikit-react-native/src/components/ReactionBottomSheets/ReactionListBottomSheet.tsx +++ b/packages/uikit-react-native/src/components/ReactionBottomSheets/ReactionListBottomSheet.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { FlatList, Pressable, View, useWindowDimensions } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; +import type { BaseMessage } from '@sendbird/chat/message'; import { Image, Modal, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation'; import { Logger } from '@sendbird/uikit-utils'; @@ -56,7 +57,10 @@ const ReactionListBottomSheet = ({ visible, onClose, onDismiss, reactionCtx, cha key={key} onPress={async () => { if (message && channel) { - const action = reacted ? channel.deleteReaction : channel.addReaction; + const action = (message: BaseMessage, key: string) => { + return reacted ? channel.deleteReaction(message, key) : channel.addReaction(message, key); + }; + action(message, key).catch((error) => { Logger.warn('Failed to reaction', error); }); diff --git a/packages/uikit-react-native/src/hooks/usePushTokenRegistration.ts b/packages/uikit-react-native/src/hooks/usePushTokenRegistration.ts index f2e381f31..84a85a7dd 100644 --- a/packages/uikit-react-native/src/hooks/usePushTokenRegistration.ts +++ b/packages/uikit-react-native/src/hooks/usePushTokenRegistration.ts @@ -21,8 +21,8 @@ const usePushTokenRegistration = () => { default: (token: string) => sdk.unregisterFCMPushTokenForCurrentUser(token), }), Platform.select({ - ios: notificationService.getAPNSToken, - default: notificationService.getFCMToken, + ios: () => notificationService.getAPNSToken(), + default: () => notificationService.getFCMToken(), }), ]; }); From 079a3638db0c84743dd067cfcc118afdaba4f7c8 Mon Sep 17 00:00:00 2001 From: bang9 Date: Mon, 28 Oct 2024 15:28:21 +0900 Subject: [PATCH 2/2] chore: skip query call if isLoading true --- packages/uikit-chat-hooks/src/common/useUserList.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/uikit-chat-hooks/src/common/useUserList.ts b/packages/uikit-chat-hooks/src/common/useUserList.ts index 247e61c43..0e985708d 100644 --- a/packages/uikit-chat-hooks/src/common/useUserList.ts +++ b/packages/uikit-chat-hooks/src/common/useUserList.ts @@ -119,7 +119,7 @@ export const useUserList = < }); const next = useFreshCallback(async () => { - if (query.current && query.current?.hasNext) { + if (query.current && query.current?.hasNext && !query.current.isLoading) { const nextUsers = await query.current.next().catch((e) => { Logger.error(e); if (e.code === SBErrorCode.UNAUTHORIZED_REQUEST) Logger.warn(SBErrorMessage.ACL);