Skip to content

Commit f0d57f5

Browse files
authored
Merge pull request #164 from sendbird/fix/avoid-conditional-hooks
fix: remove conditional hooks even if they depend on an unchanging value
2 parents 35d0316 + d02ab11 commit f0d57f5

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

packages/uikit-react-native/src/components/GroupChannelMessageRenderer/GroupChannelMessageOutgoingStatus.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ type Props = {
1515
style?: StyleProp<ImageStyle>;
1616
};
1717
const GroupChannelMessageOutgoingStatus = ({ channel, message, style }: Props) => {
18-
if (!message.isUserMessage() && !message.isFileMessage()) return null;
19-
if (channel.isEphemeral) return null;
20-
2118
const { sdk } = useSendbirdChat();
2219
const { colors } = useUIKitTheme();
2320
const outgoingStatus = useMessageOutgoingStatus(sdk, channel, message);
2421

22+
if (!message.isUserMessage() && !message.isFileMessage()) return null;
23+
if (channel.isEphemeral) return null;
24+
2525
if (outgoingStatus === 'PENDING') {
2626
return <LoadingSpinner size={SIZE} style={style} />;
2727
}

packages/uikit-react-native/src/fragments/createGroupChannelListFragment.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ const createGroupChannelListFragment = (initModule?: Partial<GroupChannelListMod
3232
markAsDelivered: confirmAndMarkAsDelivered,
3333
});
3434

35-
if (sbOptions.appInfo.deliveryReceiptEnabled) {
36-
useAppState('change', (status) => {
35+
useAppState('change', (status) => {
36+
if (sbOptions.appInfo.deliveryReceiptEnabled) {
3737
if (status === 'active') groupChannels.forEach(markAsDeliveredWithChannel);
38-
});
39-
}
38+
}
39+
});
4040

4141
const _renderGroupChannelPreview: GroupChannelListProps['List']['renderGroupChannelPreview'] = useFreshCallback(
4242
(props) => {

packages/uikit-utils/src/types.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
3-
/* eslint-disable @typescript-eslint/no-empty-interface */
42
import type React from 'react';
53

6-
import type SendbirdChat from '@sendbird/chat';
74
import type {
85
BaseChannel,
96
Emoji,
@@ -13,6 +10,7 @@ import type {
1310
Participant,
1411
RestrictedUser,
1512
SendbirdError as SBError,
13+
SendbirdChatWith,
1614
User,
1715
UserUpdateParams,
1816
} from '@sendbird/chat';
@@ -28,7 +26,6 @@ import type {
2826
MessageCollection,
2927
} from '@sendbird/chat/groupChannel';
3028
import type {
31-
ModuleNamespaces,
3229
OpenChannelCreateParams,
3330
OpenChannelUpdateParams,
3431
SendableMessage,
@@ -82,7 +79,7 @@ export type OnBeforeHandler<T> = (params: T) => T | Promise<T>;
8279
export interface UserStruct {
8380
userId: string;
8481
}
85-
export type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;
82+
export type SendbirdChatSDK = SendbirdChatWith<[GroupChannelModule, OpenChannelModule]>;
8683
export type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;
8784
export type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;
8885
export type SendbirdUserMessage = UserMessage;

0 commit comments

Comments
 (0)