Skip to content

Commit 7c99c96

Browse files
authored
Merge pull request #155 from sendbird/fix/mc-init-timing
chore(CLNP-2051): replaced useGroupChannelMessages
2 parents 6e75382 + 207ff0f commit 7c99c96

File tree

23 files changed

+87
-45
lines changed

23 files changed

+87
-45
lines changed

docs-validation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@react-native-firebase/messaging": "^14.7.0",
1616
"@react-navigation/native": "^6.0.6",
1717
"@react-navigation/native-stack": "^6.7.0",
18-
"@sendbird/chat": "^4.9.8",
18+
"@sendbird/chat": "^4.10.7",
1919
"react": "17.0.2",
2020
"react-native": "0.67.5",
2121
"react-native-create-thumbnail": "^1.5.1",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
]
9999
},
100100
"resolutions": {
101-
"@sendbird/chat": "4.9.10",
101+
"@sendbird/chat": "4.10.7",
102102
"@types/react": "^18",
103103
"@types/react-native": "^0.67"
104104
}

packages/uikit-chat-hooks/src/channel/useChannelMessagesReducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Action =
2828
}
2929
| {
3030
type: 'delete_messages' | 'delete_new_messages';
31-
value: { messageIds: number[]; reqIds: string[] };
31+
value: { messageIds: (string | number)[]; reqIds: string[] };
3232
};
3333

3434
type State = {
@@ -153,7 +153,7 @@ export const useChannelMessagesReducer = (sortComparator?: Options['sortComparat
153153
const updateMessages = (messages: SendbirdBaseMessage[], clearBeforeAction: boolean, currentUserId?: string) => {
154154
dispatch({ type: 'update_messages', value: { messages, clearBeforeAction, currentUserId } });
155155
};
156-
const deleteMessages = (messageIds: number[], reqIds: string[]) => {
156+
const deleteMessages = (messageIds: (string | number)[], reqIds: string[]) => {
157157
dispatch({ type: 'delete_messages', value: { messageIds, reqIds } });
158158
};
159159
const updateNewMessages = (messages: SendbirdBaseMessage[], clearBeforeAction: boolean, currentUserId?: string) => {

packages/uikit-chat-hooks/src/channel/useGroupChannelMessages/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import type { UseGroupChannelMessages } from '../../types';
44
import { useGroupChannelMessagesWithCollection } from './useGroupChannelMessagesWithCollection';
55
import { useGroupChannelMessagesWithQuery } from './useGroupChannelMessagesWithQuery';
66

7+
/**
8+
* @deprecated This hook is deprecated and will be replaced by the 'uikit-tools' package.
9+
* */
710
export const useGroupChannelMessages: UseGroupChannelMessages = (sdk, channel, userId, options) => {
811
if (sdk.isCacheEnabled || options?.enableCollectionWithoutLocalCache) {
912
if (options?.queryCreator) printIgnoredWarning();

packages/uikit-chat-hooks/src/channel/useGroupChannelMessages/useGroupChannelMessagesWithQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useRef } from 'react';
22

3-
import type { PreviousMessageListQueryParams } from '@sendbird/chat/message';
3+
import type { BaseMessage, PreviousMessageListQueryParams } from '@sendbird/chat/message';
44
import type {
55
SendbirdBaseChannel,
66
SendbirdGroupChannel,
@@ -116,7 +116,7 @@ export const useGroupChannelMessagesWithQuery: UseGroupChannelMessages = (sdk, c
116116
channelUrl: channel.url,
117117
channelType: channel.channelType,
118118
});
119-
if (message) updateMessages([message], false, sdk.currentUser?.userId);
119+
if (message) updateMessages([message as BaseMessage], false, sdk.currentUser?.userId);
120120
},
121121
// Channels
122122
onChannelChanged: channelUpdater,

packages/uikit-chat-hooks/src/channel/useOpenChannelMessages/useOpenChannelMessagesWithQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const useOpenChannelMessagesWithQuery: UseOpenChannelMessages = (sdk, cha
7575
const messageContext = {
7676
updatedMessages: [] as SendbirdBaseMessage[],
7777
addedMessages: [] as SendbirdBaseMessage[],
78-
deletedMessageIds: [] as number[],
78+
deletedMessageIds: [] as (number | string)[],
7979
};
8080
const changeLogsContext = {
8181
hasMore: false,

packages/uikit-chat-hooks/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export type UseGroupChannelListOptions = {
7373
};
7474

7575
/**
76+
* @deprecated This hook is deprecated and will be replaced by the 'uikit-tools' package.
77+
*
7678
* @interface UseGroupChannelMessages
7779
* @description interface for group channel messages hook
7880
* - Receive new messages from other users & should count new messages -> append to state(newMessages)

packages/uikit-react-native/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"dependencies": {
6262
"@sendbird/uikit-chat-hooks": "3.3.0",
6363
"@sendbird/uikit-react-native-foundation": "3.3.0",
64-
"@sendbird/uikit-tools": "0.0.1-alpha.42",
64+
"@sendbird/uikit-tools": "0.0.1-alpha.57",
6565
"@sendbird/uikit-utils": "3.3.0"
6666
},
6767
"devDependencies": {
@@ -107,7 +107,7 @@
107107
"@react-native-clipboard/clipboard": ">=1.8.5",
108108
"@react-native-community/netinfo": ">=9.3.0",
109109
"@react-native-firebase/messaging": ">=14.4.0",
110-
"@sendbird/chat": "^4.9.8",
110+
"@sendbird/chat": "^4.10.7",
111111
"@sendbird/react-native-scrollview-enhancer": "*",
112112
"date-fns": ">=2.28.0",
113113
"expo-av": ">=12.0.4",

packages/uikit-react-native/src/components/ChannelMessageList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
5959
onEditMessage: (message: HandleableMessage) => void;
6060
onReplyMessage?: (message: HandleableMessage) => void; // only available on group channel
6161
onDeleteMessage: (message: HandleableMessage) => Promise<void>;
62-
onResendFailedMessage: (failedMessage: HandleableMessage) => Promise<void>;
62+
onResendFailedMessage: (failedMessage: HandleableMessage) => Promise<HandleableMessage | void>;
6363
onPressParentMessage?: (parentMessage: SendbirdMessage) => void;
6464
onPressMediaMessage?: (message: SendbirdFileMessage, deleteMessage: () => Promise<void>, uri: string) => void;
6565

packages/uikit-react-native/src/components/ReactionAddons/BottomSheetReactionAddon.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { Pressable, View } from 'react-native';
33
import { useSafeAreaInsets } from 'react-native-safe-area-context';
44

5+
import type { BaseMessage } from '@sendbird/chat/message';
56
import { useChannelHandler } from '@sendbird/uikit-chat-hooks';
67
import { Icon, Image, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';
78
import { SendbirdBaseChannel, SendbirdBaseMessage, useUniqHandlerId } from '@sendbird/uikit-utils';
@@ -24,12 +25,12 @@ const BottomSheetReactionAddon = ({ onClose, message, channel }: Props) => {
2425
useChannelHandler(sdk, handlerId, {
2526
async onReactionUpdated(eventChannel, event) {
2627
if (channel?.url === eventChannel.url && event.messageId === message?.messageId) {
27-
const msg = await sdk.message.getMessage({
28+
const msg = (await sdk.message.getMessage({
2829
includeReactions: true,
2930
messageId: message.messageId,
3031
channelUrl: message.channelUrl,
3132
channelType: message.channelType,
32-
});
33+
})) as null | BaseMessage;
3334
if (msg) updateReactionFocusedItem({ message: msg });
3435
}
3536
},

0 commit comments

Comments
 (0)