@sendbird/uikit-react-native 3.7.0 → 3.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/ChannelMessageList/index.js +2 -3
- package/lib/commonjs/components/ChannelMessageList/index.js.map +1 -1
- package/lib/commonjs/components/ChannelThreadMessageList/index.js +2 -3
- package/lib/commonjs/components/ChannelThreadMessageList/index.js.map +1 -1
- package/lib/commonjs/components/GroupChannelMessageRenderer/index.js +2 -2
- package/lib/commonjs/components/GroupChannelMessageRenderer/index.js.map +1 -1
- package/lib/commonjs/components/OpenChannelMessageRenderer/index.js +2 -2
- package/lib/commonjs/components/OpenChannelMessageRenderer/index.js.map +1 -1
- package/lib/commonjs/components/ThreadParentMessageRenderer/index.js +2 -2
- package/lib/commonjs/components/ThreadParentMessageRenderer/index.js.map +1 -1
- package/lib/commonjs/containers/SendbirdUIKitContainer.js +10 -2
- package/lib/commonjs/containers/SendbirdUIKitContainer.js.map +1 -1
- package/lib/commonjs/contexts/SBUHandlersCtx.js +25 -0
- package/lib/commonjs/contexts/SBUHandlersCtx.js.map +1 -0
- package/lib/commonjs/contexts/SendbirdChatCtx.js +1 -1
- package/lib/commonjs/contexts/SendbirdChatCtx.js.map +1 -1
- package/lib/commonjs/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.js +2 -3
- package/lib/commonjs/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.js.map +1 -1
- package/lib/commonjs/hooks/useContext.js +8 -1
- package/lib/commonjs/hooks/useContext.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/components/ChannelMessageList/index.js +3 -4
- package/lib/module/components/ChannelMessageList/index.js.map +1 -1
- package/lib/module/components/ChannelThreadMessageList/index.js +3 -4
- package/lib/module/components/ChannelThreadMessageList/index.js.map +1 -1
- package/lib/module/components/GroupChannelMessageRenderer/index.js +3 -3
- package/lib/module/components/GroupChannelMessageRenderer/index.js.map +1 -1
- package/lib/module/components/OpenChannelMessageRenderer/index.js +3 -3
- package/lib/module/components/OpenChannelMessageRenderer/index.js.map +1 -1
- package/lib/module/components/ThreadParentMessageRenderer/index.js +3 -3
- package/lib/module/components/ThreadParentMessageRenderer/index.js.map +1 -1
- package/lib/module/containers/SendbirdUIKitContainer.js +10 -2
- package/lib/module/containers/SendbirdUIKitContainer.js.map +1 -1
- package/lib/module/contexts/SBUHandlersCtx.js +16 -0
- package/lib/module/contexts/SBUHandlersCtx.js.map +1 -0
- package/lib/module/contexts/SendbirdChatCtx.js +1 -1
- package/lib/module/contexts/SendbirdChatCtx.js.map +1 -1
- package/lib/module/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.js +3 -4
- package/lib/module/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.js.map +1 -1
- package/lib/module/hooks/useContext.js +6 -0
- package/lib/module/hooks/useContext.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/src/containers/SendbirdUIKitContainer.d.ts +3 -1
- package/lib/typescript/src/contexts/SBUHandlersCtx.d.ts +21 -0
- package/lib/typescript/src/hooks/useContext.d.ts +1 -0
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/components/ChannelMessageList/index.tsx +9 -4
- package/src/components/ChannelThreadMessageList/index.tsx +9 -4
- package/src/components/GroupChannelMessageRenderer/index.tsx +3 -3
- package/src/components/OpenChannelMessageRenderer/index.tsx +3 -3
- package/src/components/ThreadParentMessageRenderer/index.tsx +3 -3
- package/src/containers/SendbirdUIKitContainer.tsx +89 -77
- package/src/contexts/SBUHandlersCtx.tsx +27 -0
- package/src/contexts/SendbirdChatCtx.tsx +1 -1
- package/src/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.tsx +3 -4
- package/src/hooks/useContext.ts +7 -0
- package/src/version.ts +1 -1
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
import { LocalizationContext, LocalizationProvider } from '../contexts/LocalizationCtx';
|
|
33
33
|
import { PlatformServiceProvider } from '../contexts/PlatformServiceCtx';
|
|
34
34
|
import { ReactionProvider } from '../contexts/ReactionCtx';
|
|
35
|
+
import { type SBUHandlers, SBUHandlersProvider } from '../contexts/SBUHandlersCtx';
|
|
35
36
|
import type { ChatRelatedFeaturesInUIKit } from '../contexts/SendbirdChatCtx';
|
|
36
37
|
import { SendbirdChatProvider } from '../contexts/SendbirdChatCtx';
|
|
37
38
|
import { UserProfileProvider } from '../contexts/UserProfileCtx';
|
|
@@ -41,6 +42,7 @@ import ImageCompressionConfig from '../libs/ImageCompressionConfig';
|
|
|
41
42
|
import InternalLocalCacheStorage from '../libs/InternalLocalCacheStorage';
|
|
42
43
|
import MentionConfig, { MentionConfigInterface } from '../libs/MentionConfig';
|
|
43
44
|
import MentionManager from '../libs/MentionManager';
|
|
45
|
+
import SBUUtils from '../libs/SBUUtils';
|
|
44
46
|
import VoiceMessageConfig, { VoiceMessageConfigInterface } from '../libs/VoiceMessageConfig';
|
|
45
47
|
import VoiceMessageStatusManager from '../libs/VoiceMessageStatusManager';
|
|
46
48
|
import StringSetEn from '../localization/StringSet.en';
|
|
@@ -131,6 +133,7 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
|
|
|
131
133
|
onError?: (props: ErrorBoundaryProps) => void;
|
|
132
134
|
ErrorInfoComponent?: (props: ErrorBoundaryProps) => React.ReactNode;
|
|
133
135
|
};
|
|
136
|
+
handlers?: Partial<SBUHandlers>;
|
|
134
137
|
toast?: {
|
|
135
138
|
dismissTimeout?: number;
|
|
136
139
|
};
|
|
@@ -159,6 +162,7 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
|
|
|
159
162
|
localization,
|
|
160
163
|
styles,
|
|
161
164
|
errorBoundary,
|
|
165
|
+
handlers,
|
|
162
166
|
toast,
|
|
163
167
|
userProfile,
|
|
164
168
|
reaction,
|
|
@@ -213,85 +217,93 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
|
|
|
213
217
|
}
|
|
214
218
|
};
|
|
215
219
|
|
|
220
|
+
const sbuHandlers: SBUHandlers = {
|
|
221
|
+
onOpenURL: SBUUtils.openURL,
|
|
222
|
+
onOpenFileURL: SBUUtils.openURL,
|
|
223
|
+
...handlers,
|
|
224
|
+
};
|
|
225
|
+
|
|
216
226
|
return (
|
|
217
|
-
<
|
|
218
|
-
<
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
<SendbirdChatProvider
|
|
233
|
-
sdkInstance={sdkInstance}
|
|
234
|
-
emojiManager={emojiManager}
|
|
235
|
-
mentionManager={mentionManager}
|
|
236
|
-
imageCompressionConfig={imageCompressionConfig}
|
|
237
|
-
voiceMessageConfig={voiceMessageConfig}
|
|
238
|
-
voiceMessageStatusManager={voiceMessageStatusManager}
|
|
239
|
-
enableAutoPushTokenRegistration={
|
|
240
|
-
chatOptions.enableAutoPushTokenRegistration ?? SendbirdUIKit.DEFAULT.AUTO_PUSH_TOKEN_REGISTRATION
|
|
241
|
-
}
|
|
242
|
-
enableUseUserIdForNickname={
|
|
243
|
-
chatOptions.enableUseUserIdForNickname ?? SendbirdUIKit.DEFAULT.USE_USER_ID_FOR_NICKNAME
|
|
244
|
-
}
|
|
245
|
-
enableImageCompression={chatOptions.enableImageCompression ?? SendbirdUIKit.DEFAULT.IMAGE_COMPRESSION}
|
|
227
|
+
<SBUHandlersProvider {...sbuHandlers}>
|
|
228
|
+
<SafeAreaProvider>
|
|
229
|
+
<UIKitConfigProvider
|
|
230
|
+
storage={internalStorage}
|
|
231
|
+
localConfigs={{
|
|
232
|
+
common: uikitOptions?.common,
|
|
233
|
+
groupChannel: {
|
|
234
|
+
channel: { ...uikitOptions?.groupChannel, enableReactionsSupergroup: undefined },
|
|
235
|
+
channelList: uikitOptions?.groupChannelList,
|
|
236
|
+
setting: uikitOptions?.groupChannelSettings,
|
|
237
|
+
},
|
|
238
|
+
openChannel: {
|
|
239
|
+
channel: uikitOptions?.openChannel,
|
|
240
|
+
},
|
|
241
|
+
}}
|
|
246
242
|
>
|
|
247
|
-
<
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
)
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
243
|
+
<SendbirdChatProvider
|
|
244
|
+
sdkInstance={sdkInstance}
|
|
245
|
+
emojiManager={emojiManager}
|
|
246
|
+
mentionManager={mentionManager}
|
|
247
|
+
imageCompressionConfig={imageCompressionConfig}
|
|
248
|
+
voiceMessageConfig={voiceMessageConfig}
|
|
249
|
+
voiceMessageStatusManager={voiceMessageStatusManager}
|
|
250
|
+
enableAutoPushTokenRegistration={
|
|
251
|
+
chatOptions.enableAutoPushTokenRegistration ?? SendbirdUIKit.DEFAULT.AUTO_PUSH_TOKEN_REGISTRATION
|
|
252
|
+
}
|
|
253
|
+
enableUseUserIdForNickname={
|
|
254
|
+
chatOptions.enableUseUserIdForNickname ?? SendbirdUIKit.DEFAULT.USE_USER_ID_FOR_NICKNAME
|
|
255
|
+
}
|
|
256
|
+
enableImageCompression={chatOptions.enableImageCompression ?? SendbirdUIKit.DEFAULT.IMAGE_COMPRESSION}
|
|
257
|
+
>
|
|
258
|
+
<LocalizationProvider stringSet={defaultStringSet}>
|
|
259
|
+
<PlatformServiceProvider
|
|
260
|
+
fileService={platformServices.file}
|
|
261
|
+
notificationService={platformServices.notification}
|
|
262
|
+
clipboardService={platformServices.clipboard}
|
|
263
|
+
mediaService={platformServices.media}
|
|
264
|
+
playerService={platformServices.player}
|
|
265
|
+
recorderService={platformServices.recorder}
|
|
266
|
+
voiceMessageConfig={voiceMessageConfig}
|
|
267
|
+
>
|
|
268
|
+
<UIKitThemeProvider theme={styles?.theme ?? LightUIKitTheme}>
|
|
269
|
+
<HeaderStyleProvider
|
|
270
|
+
HeaderComponent={styles?.HeaderComponent ?? Header}
|
|
271
|
+
defaultTitleAlign={styles?.defaultHeaderTitleAlign ?? 'left'}
|
|
272
|
+
statusBarTranslucent={styles?.statusBarTranslucent ?? true}
|
|
273
|
+
>
|
|
274
|
+
<ToastProvider dismissTimeout={toast?.dismissTimeout}>
|
|
275
|
+
<UserProfileProvider {...userProfile} statusBarTranslucent={styles?.statusBarTranslucent ?? true}>
|
|
276
|
+
<ReactionProvider {...reaction}>
|
|
277
|
+
<LocalizationContext.Consumer>
|
|
278
|
+
{(value) => {
|
|
279
|
+
const STRINGS = value?.STRINGS || defaultStringSet;
|
|
280
|
+
return (
|
|
281
|
+
<DialogProvider
|
|
282
|
+
defaultLabels={{
|
|
283
|
+
alert: { ok: STRINGS.DIALOG.ALERT_DEFAULT_OK },
|
|
284
|
+
prompt: {
|
|
285
|
+
ok: STRINGS.DIALOG.PROMPT_DEFAULT_OK,
|
|
286
|
+
cancel: STRINGS.DIALOG.PROMPT_DEFAULT_CANCEL,
|
|
287
|
+
placeholder: STRINGS.DIALOG.PROMPT_DEFAULT_PLACEHOLDER,
|
|
288
|
+
},
|
|
289
|
+
}}
|
|
290
|
+
>
|
|
291
|
+
{renderChildren()}
|
|
292
|
+
</DialogProvider>
|
|
293
|
+
);
|
|
294
|
+
}}
|
|
295
|
+
</LocalizationContext.Consumer>
|
|
296
|
+
</ReactionProvider>
|
|
297
|
+
</UserProfileProvider>
|
|
298
|
+
</ToastProvider>
|
|
299
|
+
</HeaderStyleProvider>
|
|
300
|
+
</UIKitThemeProvider>
|
|
301
|
+
</PlatformServiceProvider>
|
|
302
|
+
</LocalizationProvider>
|
|
303
|
+
</SendbirdChatProvider>
|
|
304
|
+
</UIKitConfigProvider>
|
|
305
|
+
</SafeAreaProvider>
|
|
306
|
+
</SBUHandlersProvider>
|
|
295
307
|
);
|
|
296
308
|
};
|
|
297
309
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface SBUHandlers {
|
|
4
|
+
/**
|
|
5
|
+
* Callback function to handle opening a URL.
|
|
6
|
+
* This is triggered when a URL needs to be opened.
|
|
7
|
+
*/
|
|
8
|
+
onOpenURL: (url: string) => void;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Callback function to handle opening a file URL.
|
|
12
|
+
* This is triggered when a file URL needs to be opened.
|
|
13
|
+
*
|
|
14
|
+
* Note that this function is also called redundantly
|
|
15
|
+
* when `onPressMediaMessage` handler is triggered by clicking on media messages containing images, videos, or audio.
|
|
16
|
+
*/
|
|
17
|
+
onOpenFileURL: (url: string) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Props = React.PropsWithChildren<SBUHandlers>;
|
|
21
|
+
|
|
22
|
+
export type SBUHandlersContextType = SBUHandlers;
|
|
23
|
+
|
|
24
|
+
export const SBUHandlersContext = React.createContext<SBUHandlersContextType | null>(null);
|
|
25
|
+
export const SBUHandlersProvider = ({ children, onOpenURL, onOpenFileURL }: Props) => {
|
|
26
|
+
return <SBUHandlersContext.Provider value={{ onOpenURL, onOpenFileURL }}>{children}</SBUHandlersContext.Provider>;
|
|
27
|
+
};
|
|
@@ -170,7 +170,7 @@ export const SendbirdChatProvider = ({
|
|
|
170
170
|
|
|
171
171
|
useEffect(() => {
|
|
172
172
|
return () => {
|
|
173
|
-
sdkInstance.
|
|
173
|
+
sdkInstance.disconnectWebSocket().then(() => _setCurrentUser(undefined));
|
|
174
174
|
};
|
|
175
175
|
}, [sdkInstance]);
|
|
176
176
|
|
|
@@ -30,8 +30,7 @@ import {
|
|
|
30
30
|
import ThreadParentMessageRenderer, {
|
|
31
31
|
ThreadParentMessageRendererProps,
|
|
32
32
|
} from '../../../components/ThreadParentMessageRenderer';
|
|
33
|
-
import { useLocalization, usePlatformService, useSendbirdChat } from '../../../hooks/useContext';
|
|
34
|
-
import SBUUtils from '../../../libs/SBUUtils';
|
|
33
|
+
import { useLocalization, usePlatformService, useSBUHandlers, useSendbirdChat } from '../../../hooks/useContext';
|
|
35
34
|
import { GroupChannelThreadContexts } from '../module/moduleContext';
|
|
36
35
|
import type { GroupChannelThreadProps } from '../types';
|
|
37
36
|
import { ReactionAddons } from './../../../components/ReactionAddons';
|
|
@@ -182,6 +181,7 @@ const useCreateMessagePressActions = ({
|
|
|
182
181
|
GroupChannelThreadProps['ParentMessageInfo'],
|
|
183
182
|
'channel' | 'currentUserId' | 'onDeleteMessage' | 'onPressMediaMessage'
|
|
184
183
|
> & { onEditMessage: (message: HandleableMessage) => void }): CreateMessagePressActions => {
|
|
184
|
+
const handlers = useSBUHandlers();
|
|
185
185
|
const { STRINGS } = useLocalization();
|
|
186
186
|
const toast = useToast();
|
|
187
187
|
const { openSheet } = useBottomSheet();
|
|
@@ -225,9 +225,8 @@ const useCreateMessagePressActions = ({
|
|
|
225
225
|
const fileType = getFileType(message.type || getFileExtension(message.name));
|
|
226
226
|
if (['image', 'video', 'audio'].includes(fileType)) {
|
|
227
227
|
onPressMediaMessage?.(message, () => onDeleteMessage?.(message), getAvailableUriFromFileMessage(message));
|
|
228
|
-
} else {
|
|
229
|
-
SBUUtils.openURL(message.url);
|
|
230
228
|
}
|
|
229
|
+
handlers.onOpenFileURL(message.url);
|
|
231
230
|
}
|
|
232
231
|
};
|
|
233
232
|
|
package/src/hooks/useContext.ts
CHANGED
|
@@ -3,9 +3,16 @@ import { useContext } from 'react';
|
|
|
3
3
|
import { LocalizationContext } from '../contexts/LocalizationCtx';
|
|
4
4
|
import { PlatformServiceContext } from '../contexts/PlatformServiceCtx';
|
|
5
5
|
import { ReactionContext } from '../contexts/ReactionCtx';
|
|
6
|
+
import { SBUHandlersContext } from '../contexts/SBUHandlersCtx';
|
|
6
7
|
import { SendbirdChatContext } from '../contexts/SendbirdChatCtx';
|
|
7
8
|
import { UserProfileContext } from '../contexts/UserProfileCtx';
|
|
8
9
|
|
|
10
|
+
export const useSBUHandlers = () => {
|
|
11
|
+
const value = useContext(SBUHandlersContext);
|
|
12
|
+
if (!value) throw new Error('SBUHandlersContext is not provided');
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
|
|
9
16
|
export const useLocalization = () => {
|
|
10
17
|
const value = useContext(LocalizationContext);
|
|
11
18
|
if (!value) throw new Error('LocalizationContext is not provided');
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const VERSION = '3.7.
|
|
1
|
+
const VERSION = '3.7.2';
|
|
2
2
|
export default VERSION;
|