Skip to content

Commit

Permalink
Merge pull request #209 from sendbird/fix/this-binding-issues
Browse files Browse the repository at this point in the history
fix: resolve this binding issues
  • Loading branch information
bang9 authored Oct 28, 2024
2 parents 9547065 + 079a363 commit b0ad96b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/uikit-chat-hooks/src/common/useUserList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}),
];
});
Expand Down

0 comments on commit b0ad96b

Please sign in to comment.