Skip to content

Commit

Permalink
Merge pull request #164 from sendbird/fix/avoid-conditional-hooks
Browse files Browse the repository at this point in the history
fix: remove conditional hooks even if they depend on an unchanging value
  • Loading branch information
bang9 authored Feb 23, 2024
2 parents 35d0316 + d02ab11 commit f0d57f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type Props = {
style?: StyleProp<ImageStyle>;
};
const GroupChannelMessageOutgoingStatus = ({ channel, message, style }: Props) => {
if (!message.isUserMessage() && !message.isFileMessage()) return null;
if (channel.isEphemeral) return null;

const { sdk } = useSendbirdChat();
const { colors } = useUIKitTheme();
const outgoingStatus = useMessageOutgoingStatus(sdk, channel, message);

if (!message.isUserMessage() && !message.isFileMessage()) return null;
if (channel.isEphemeral) return null;

if (outgoingStatus === 'PENDING') {
return <LoadingSpinner size={SIZE} style={style} />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const createGroupChannelListFragment = (initModule?: Partial<GroupChannelListMod
markAsDelivered: confirmAndMarkAsDelivered,
});

if (sbOptions.appInfo.deliveryReceiptEnabled) {
useAppState('change', (status) => {
useAppState('change', (status) => {
if (sbOptions.appInfo.deliveryReceiptEnabled) {
if (status === 'active') groupChannels.forEach(markAsDeliveredWithChannel);
});
}
}
});

const _renderGroupChannelPreview: GroupChannelListProps['List']['renderGroupChannelPreview'] = useFreshCallback(
(props) => {
Expand Down
7 changes: 2 additions & 5 deletions packages/uikit-utils/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

/* eslint-disable @typescript-eslint/no-empty-interface */
import type React from 'react';

import type SendbirdChat from '@sendbird/chat';
import type {
BaseChannel,
Emoji,
Expand All @@ -13,6 +10,7 @@ import type {
Participant,
RestrictedUser,
SendbirdError as SBError,
SendbirdChatWith,
User,
UserUpdateParams,
} from '@sendbird/chat';
Expand All @@ -28,7 +26,6 @@ import type {
MessageCollection,
} from '@sendbird/chat/groupChannel';
import type {
ModuleNamespaces,
OpenChannelCreateParams,
OpenChannelUpdateParams,
SendableMessage,
Expand Down Expand Up @@ -82,7 +79,7 @@ export type OnBeforeHandler<T> = (params: T) => T | Promise<T>;
export interface UserStruct {
userId: string;
}
export type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;
export type SendbirdChatSDK = SendbirdChatWith<[GroupChannelModule, OpenChannelModule]>;
export type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;
export type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;
export type SendbirdUserMessage = UserMessage;
Expand Down

0 comments on commit f0d57f5

Please sign in to comment.