@sendbird/uikit-react-native 2.0.2 → 2.0.3
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/README.md +2 -2
- package/lib/commonjs/components/MessageRenderer/MessageIncomingAvatar.js +2 -9
- package/lib/commonjs/components/MessageRenderer/MessageIncomingAvatar.js.map +1 -1
- package/lib/commonjs/components/UserActionBar.js +4 -7
- package/lib/commonjs/components/UserActionBar.js.map +1 -1
- package/lib/commonjs/containers/GroupChannelPreviewContainer.js +4 -23
- package/lib/commonjs/containers/GroupChannelPreviewContainer.js.map +1 -1
- package/lib/commonjs/containers/SendbirdUIKitContainer.js +7 -13
- package/lib/commonjs/containers/SendbirdUIKitContainer.js.map +1 -1
- package/lib/commonjs/contexts/{LocalizationCtx.js → Localization.js} +1 -1
- package/lib/commonjs/contexts/Localization.js.map +1 -0
- package/lib/commonjs/contexts/{PlatformServiceCtx.js → PlatformService.js} +1 -1
- package/lib/commonjs/contexts/PlatformService.js.map +1 -0
- package/lib/commonjs/contexts/{SendbirdChatCtx.js → SendbirdChat.js} +1 -1
- package/lib/commonjs/contexts/SendbirdChat.js.map +1 -0
- package/lib/commonjs/domain/groupChannelList/types.js.map +1 -1
- package/lib/commonjs/fragments/createGroupChannelFragment.js +1 -9
- package/lib/commonjs/fragments/createGroupChannelFragment.js.map +1 -1
- package/lib/commonjs/fragments/createGroupChannelListFragment.js +3 -2
- package/lib/commonjs/fragments/createGroupChannelListFragment.js.map +1 -1
- package/lib/commonjs/fragments/createGroupChannelMembersFragment.js +11 -11
- package/lib/commonjs/fragments/createGroupChannelMembersFragment.js.map +1 -1
- package/lib/commonjs/hooks/useContext.js +7 -17
- package/lib/commonjs/hooks/useContext.js.map +1 -1
- package/lib/commonjs/index.js +9 -32
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/localization/StringSet.type.js +0 -6
- package/lib/commonjs/localization/StringSet.type.js.map +1 -1
- package/lib/commonjs/platform/createFileService.native.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/components/MessageRenderer/MessageIncomingAvatar.js +3 -9
- package/lib/module/components/MessageRenderer/MessageIncomingAvatar.js.map +1 -1
- package/lib/module/components/UserActionBar.js +5 -8
- package/lib/module/components/UserActionBar.js.map +1 -1
- package/lib/module/containers/GroupChannelPreviewContainer.js +4 -23
- package/lib/module/containers/GroupChannelPreviewContainer.js.map +1 -1
- package/lib/module/containers/SendbirdUIKitContainer.js +4 -9
- package/lib/module/containers/SendbirdUIKitContainer.js.map +1 -1
- package/lib/module/contexts/{LocalizationCtx.js → Localization.js} +1 -1
- package/lib/module/contexts/Localization.js.map +1 -0
- package/lib/module/contexts/{PlatformServiceCtx.js → PlatformService.js} +1 -1
- package/lib/module/contexts/PlatformService.js.map +1 -0
- package/lib/module/contexts/{SendbirdChatCtx.js → SendbirdChat.js} +1 -1
- package/lib/module/contexts/SendbirdChat.js.map +1 -0
- package/lib/module/domain/groupChannelList/types.js.map +1 -1
- package/lib/module/fragments/createGroupChannelFragment.js +1 -9
- package/lib/module/fragments/createGroupChannelFragment.js.map +1 -1
- package/lib/module/fragments/createGroupChannelListFragment.js +3 -2
- package/lib/module/fragments/createGroupChannelListFragment.js.map +1 -1
- package/lib/module/fragments/createGroupChannelMembersFragment.js +9 -13
- package/lib/module/fragments/createGroupChannelMembersFragment.js.map +1 -1
- package/lib/module/hooks/useContext.js +3 -9
- package/lib/module/hooks/useContext.js.map +1 -1
- package/lib/module/index.js +4 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/localization/StringSet.type.js +0 -6
- package/lib/module/localization/StringSet.type.js.map +1 -1
- package/lib/module/platform/createFileService.native.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/src/components/UserActionBar.d.ts +2 -4
- package/lib/typescript/src/containers/SendbirdUIKitContainer.d.ts +3 -7
- package/lib/typescript/src/contexts/{LocalizationCtx.d.ts → Localization.d.ts} +0 -0
- package/lib/typescript/src/contexts/{PlatformServiceCtx.d.ts → PlatformService.d.ts} +0 -0
- package/lib/typescript/src/contexts/{SendbirdChatCtx.d.ts → SendbirdChat.d.ts} +0 -0
- package/lib/typescript/src/domain/groupChannelList/types.d.ts +0 -2
- package/lib/typescript/src/hooks/useContext.d.ts +1 -2
- package/lib/typescript/src/index.d.ts +4 -5
- package/lib/typescript/src/localization/StringSet.type.d.ts +1 -6
- package/lib/typescript/src/platform/createFileService.native.d.ts +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +9 -9
- package/src/components/MessageRenderer/MessageIncomingAvatar.tsx +2 -9
- package/src/components/UserActionBar.tsx +4 -10
- package/src/containers/GroupChannelPreviewContainer.tsx +1 -20
- package/src/containers/SendbirdUIKitContainer.tsx +6 -26
- package/src/contexts/{LocalizationCtx.tsx → Localization.tsx} +0 -0
- package/src/contexts/{PlatformServiceCtx.tsx → PlatformService.tsx} +0 -0
- package/src/contexts/{SendbirdChatCtx.tsx → SendbirdChat.tsx} +0 -0
- package/src/domain/groupChannelList/types.ts +2 -2
- package/src/fragments/createGroupChannelFragment.tsx +8 -18
- package/src/fragments/createGroupChannelListFragment.tsx +3 -2
- package/src/fragments/createGroupChannelMembersFragment.tsx +25 -25
- package/src/hooks/useContext.ts +3 -10
- package/src/index.ts +4 -5
- package/src/localization/StringSet.type.ts +0 -12
- package/src/platform/createFileService.native.ts +1 -1
- package/src/version.ts +1 -1
- package/lib/commonjs/contexts/LocalizationCtx.js.map +0 -1
- package/lib/commonjs/contexts/PlatformServiceCtx.js.map +0 -1
- package/lib/commonjs/contexts/ProfileCardCtx.js +0 -119
- package/lib/commonjs/contexts/ProfileCardCtx.js.map +0 -1
- package/lib/commonjs/contexts/SendbirdChatCtx.js.map +0 -1
- package/lib/module/contexts/LocalizationCtx.js.map +0 -1
- package/lib/module/contexts/PlatformServiceCtx.js.map +0 -1
- package/lib/module/contexts/ProfileCardCtx.js +0 -97
- package/lib/module/contexts/ProfileCardCtx.js.map +0 -1
- package/lib/module/contexts/SendbirdChatCtx.js.map +0 -1
- package/lib/typescript/src/contexts/ProfileCardCtx.d.ts +0 -15
- package/src/contexts/ProfileCardCtx.tsx +0 -125
|
@@ -89,24 +89,10 @@ const GroupChannelPreviewContainer = ({ onPress, onLongPress, channel }: Props)
|
|
|
89
89
|
return undefined;
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
const customCover = useIIFE(() => {
|
|
93
|
-
if (channel.isBroadcast) {
|
|
94
|
-
return (
|
|
95
|
-
<Icon
|
|
96
|
-
icon={'broadcast'}
|
|
97
|
-
size={32}
|
|
98
|
-
color={colors.onBackgroundReverse01}
|
|
99
|
-
containerStyle={[styles.broadcastCover, { backgroundColor: colors.secondary }]}
|
|
100
|
-
/>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
return <ChannelCover channel={channel} size={56} />;
|
|
104
|
-
});
|
|
105
|
-
|
|
106
92
|
return (
|
|
107
93
|
<Pressable delayLongPress={DEFAULT_LONG_PRESS_DELAY} onPress={onPress} onLongPress={onLongPress}>
|
|
108
94
|
<GroupChannelPreview
|
|
109
|
-
customCover={
|
|
95
|
+
customCover={<ChannelCover channel={channel} size={56} />}
|
|
110
96
|
coverUrl={channel.coverUrl}
|
|
111
97
|
title={STRINGS.GROUP_CHANNEL_LIST.CHANNEL_PREVIEW_TITLE(currentUser?.userId ?? '', channel)}
|
|
112
98
|
titleCaptionLeft={titleCaptionIcon}
|
|
@@ -116,7 +102,6 @@ const GroupChannelPreviewContainer = ({ onPress, onLongPress, channel }: Props)
|
|
|
116
102
|
badgeCount={channel.unreadMessageCount}
|
|
117
103
|
memberCount={channel.memberCount > 2 ? channel.memberCount : undefined}
|
|
118
104
|
frozen={channel.isFrozen}
|
|
119
|
-
broadcast={channel.isBroadcast}
|
|
120
105
|
notificationOff={channel.myPushTriggerOption === 'off'}
|
|
121
106
|
/>
|
|
122
107
|
</Pressable>
|
|
@@ -127,10 +112,6 @@ const styles = createStyleSheet({
|
|
|
127
112
|
titleCaptionIcon: {
|
|
128
113
|
marginRight: 4,
|
|
129
114
|
},
|
|
130
|
-
broadcastCover: {
|
|
131
|
-
padding: 12,
|
|
132
|
-
borderRadius: 28,
|
|
133
|
-
},
|
|
134
115
|
});
|
|
135
116
|
|
|
136
117
|
export default GroupChannelPreviewContainer;
|
|
@@ -14,18 +14,11 @@ import {
|
|
|
14
14
|
ToastProvider,
|
|
15
15
|
UIKitThemeProvider,
|
|
16
16
|
} from '@sendbird/uikit-react-native-foundation';
|
|
17
|
-
import type {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
SendbirdUser,
|
|
23
|
-
} from '@sendbird/uikit-utils';
|
|
24
|
-
|
|
25
|
-
import { LocalizationProvider } from '../contexts/LocalizationCtx';
|
|
26
|
-
import { PlatformServiceProvider } from '../contexts/PlatformServiceCtx';
|
|
27
|
-
import { ProfileCardProvider } from '../contexts/ProfileCardCtx';
|
|
28
|
-
import { SendbirdChatProvider } from '../contexts/SendbirdChatCtx';
|
|
17
|
+
import type { SendbirdChatSDK } from '@sendbird/uikit-utils';
|
|
18
|
+
|
|
19
|
+
import { LocalizationProvider } from '../contexts/Localization';
|
|
20
|
+
import { PlatformServiceProvider } from '../contexts/PlatformService';
|
|
21
|
+
import { SendbirdChatProvider } from '../contexts/SendbirdChat';
|
|
29
22
|
import { useLocalization } from '../hooks/useContext';
|
|
30
23
|
import InternalLocalCacheStorage from '../libs/InternalLocalCacheStorage';
|
|
31
24
|
import StringSetEn from '../localization/StringSet.en';
|
|
@@ -76,13 +69,6 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
|
|
|
76
69
|
toast?: {
|
|
77
70
|
dismissTimeout?: number;
|
|
78
71
|
};
|
|
79
|
-
profileCard?: {
|
|
80
|
-
onCreateChannel: (channel: SendbirdGroupChannel) => void;
|
|
81
|
-
onBeforeCreateChannel?: (
|
|
82
|
-
channelParams: SendbirdGroupChannelCreateParams,
|
|
83
|
-
users: SendbirdUser[] | SendbirdMember[],
|
|
84
|
-
) => SendbirdGroupChannelCreateParams | Promise<SendbirdGroupChannelCreateParams>;
|
|
85
|
-
};
|
|
86
72
|
errorBoundary?: {
|
|
87
73
|
onError?: (props: ErrorBoundaryProps) => void;
|
|
88
74
|
ErrorInfoComponent?: (props: ErrorBoundaryProps) => JSX.Element;
|
|
@@ -97,7 +83,6 @@ const SendbirdUIKitContainer = ({
|
|
|
97
83
|
localization,
|
|
98
84
|
styles,
|
|
99
85
|
toast,
|
|
100
|
-
profileCard,
|
|
101
86
|
errorBoundary,
|
|
102
87
|
}: SendbirdUIKitContainerProps) => {
|
|
103
88
|
const unsubscribes = useRef<(() => void)[]>([]).current;
|
|
@@ -178,12 +163,7 @@ const SendbirdUIKitContainer = ({
|
|
|
178
163
|
>
|
|
179
164
|
<LocalizedDialogProvider>
|
|
180
165
|
<ToastProvider dismissTimeout={toast?.dismissTimeout}>
|
|
181
|
-
<
|
|
182
|
-
onCreateChannel={profileCard?.onCreateChannel}
|
|
183
|
-
onBeforeCreateChannel={profileCard?.onBeforeCreateChannel}
|
|
184
|
-
>
|
|
185
|
-
<InternalErrorBoundaryContainer {...errorBoundary}>{children}</InternalErrorBoundaryContainer>
|
|
186
|
-
</ProfileCardProvider>
|
|
166
|
+
<InternalErrorBoundaryContainer {...errorBoundary}>{children}</InternalErrorBoundaryContainer>
|
|
187
167
|
</ToastProvider>
|
|
188
168
|
</LocalizedDialogProvider>
|
|
189
169
|
</HeaderStyleProvider>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -23,8 +23,8 @@ export interface GroupChannelListProps {
|
|
|
23
23
|
channel: SendbirdGroupChannel,
|
|
24
24
|
onLongPressChannel: () => void,
|
|
25
25
|
) => React.ReactElement | null;
|
|
26
|
-
/** Skip type selection, When this is set to true 'channelType' only receive 'GROUP' type **/
|
|
27
|
-
skipTypeSelection?: boolean;
|
|
26
|
+
// /** Skip type selection, When this is set to true 'channelType' only receive 'GROUP' type **/
|
|
27
|
+
// skipTypeSelection?: boolean;
|
|
28
28
|
/** Custom Query creator for channels query **/
|
|
29
29
|
queryCreator?: UseGroupChannelListOptions['queryCreator'];
|
|
30
30
|
/** Custom Collection creator for group channel collection **/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useGroupChannelMessages } from '@sendbird/uikit-chat-hooks';
|
|
4
|
-
import { NOOP, PASS,
|
|
4
|
+
import { NOOP, PASS, messageComparator, useFreshCallback } from '@sendbird/uikit-utils';
|
|
5
5
|
|
|
6
6
|
import MessageRenderer from '../components/MessageRenderer';
|
|
7
7
|
import NewMessagesButton from '../components/NewMessagesButton';
|
|
@@ -119,27 +119,17 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
|
|
|
119
119
|
onPressMediaMessage={onPressMediaMessage}
|
|
120
120
|
flatListProps={memoizedFlatListProps}
|
|
121
121
|
/>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/>
|
|
130
|
-
)}
|
|
122
|
+
<GroupChannelModule.Input
|
|
123
|
+
channel={activeChannel}
|
|
124
|
+
onSendFileMessage={onSendFileMessage}
|
|
125
|
+
onSendUserMessage={onSendUserMessage}
|
|
126
|
+
onUpdateFileMessage={onUpdateFileMessage}
|
|
127
|
+
onUpdateUserMessage={onUpdateUserMessage}
|
|
128
|
+
/>
|
|
131
129
|
</StatusComposition>
|
|
132
130
|
</GroupChannelModule.Provider>
|
|
133
131
|
);
|
|
134
132
|
};
|
|
135
133
|
};
|
|
136
134
|
|
|
137
|
-
function shouldRenderInput(channel: SendbirdGroupChannel) {
|
|
138
|
-
if (channel.isBroadcast) {
|
|
139
|
-
return channel.myRole === 'operator';
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
135
|
export default createGroupChannelFragment;
|
|
@@ -23,7 +23,7 @@ const createGroupChannelListFragment = (initModule?: Partial<GroupChannelListMod
|
|
|
23
23
|
queryCreator,
|
|
24
24
|
collectionCreator,
|
|
25
25
|
renderGroupChannelPreview,
|
|
26
|
-
skipTypeSelection =
|
|
26
|
+
// skipTypeSelection = true,
|
|
27
27
|
flatListProps = {},
|
|
28
28
|
menuItemCreator = PASS,
|
|
29
29
|
}) => {
|
|
@@ -78,7 +78,8 @@ const createGroupChannelListFragment = (initModule?: Partial<GroupChannelListMod
|
|
|
78
78
|
/>
|
|
79
79
|
</StatusComposition>
|
|
80
80
|
<GroupChannelListModule.TypeSelector
|
|
81
|
-
|
|
81
|
+
// NOTE: not included in first iteration
|
|
82
|
+
skipTypeSelection
|
|
82
83
|
Header={TypeSelectorHeader}
|
|
83
84
|
onSelectType={onPressCreateChannel}
|
|
84
85
|
/>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useActiveGroupChannel, useChannelHandler } from '@sendbird/uikit-chat-hooks';
|
|
4
4
|
import { Icon } from '@sendbird/uikit-react-native-foundation';
|
|
5
5
|
import type { SendbirdMember } from '@sendbird/uikit-utils';
|
|
6
|
-
import { useForceUpdate,
|
|
6
|
+
import { useForceUpdate, useUniqId } from '@sendbird/uikit-utils';
|
|
7
7
|
|
|
8
8
|
import UserActionBar from '../components/UserActionBar';
|
|
9
9
|
import type { GroupChannelMembersFragment } from '../domain/groupChannelUserList/types';
|
|
10
10
|
import createUserListModule from '../domain/userList/module/createUserListModule';
|
|
11
11
|
import type { UserListModule } from '../domain/userList/types';
|
|
12
|
-
import { useLocalization,
|
|
12
|
+
import { useLocalization, useSendbirdChat } from '../hooks/useContext';
|
|
13
13
|
|
|
14
14
|
const noop = () => '';
|
|
15
15
|
const name = 'createGroupChannelMembersFragment';
|
|
@@ -21,13 +21,11 @@ const createGroupChannelMembersFragment = (
|
|
|
21
21
|
return ({ channel, onPressHeaderLeft, onPressHeaderRight, renderUser }) => {
|
|
22
22
|
const uniqId = useUniqId(name);
|
|
23
23
|
const forceUpdate = useForceUpdate();
|
|
24
|
-
|
|
25
|
-
const { STRINGS } = useLocalization();
|
|
26
24
|
const { sdk, currentUser } = useSendbirdChat();
|
|
27
|
-
const { show } = useProfileCard();
|
|
28
|
-
|
|
29
25
|
const { activeChannel } = useActiveGroupChannel(sdk, channel);
|
|
30
26
|
|
|
27
|
+
const { STRINGS } = useLocalization();
|
|
28
|
+
|
|
31
29
|
useChannelHandler(sdk, `${name}_${uniqId}`, {
|
|
32
30
|
// Note: Removed from v4
|
|
33
31
|
// onUserEntered(channel) {
|
|
@@ -65,25 +63,27 @@ const createGroupChannelMembersFragment = (
|
|
|
65
63
|
},
|
|
66
64
|
});
|
|
67
65
|
|
|
68
|
-
const _renderUser: NonNullable<typeof renderUser> =
|
|
69
|
-
|
|
66
|
+
const _renderUser: NonNullable<typeof renderUser> = useCallback(
|
|
67
|
+
(user, selectedUsers, setSelectedUsers) => {
|
|
68
|
+
if (renderUser) return renderUser(user, selectedUsers, setSelectedUsers);
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
70
|
+
return (
|
|
71
|
+
<UserActionBar
|
|
72
|
+
muted={user.isMuted}
|
|
73
|
+
uri={user.profileUrl}
|
|
74
|
+
label={user.role === 'operator' ? STRINGS.GROUP_CHANNEL_MEMBERS.USER_BAR_OPERATOR : ''}
|
|
75
|
+
name={
|
|
76
|
+
(user.nickname || STRINGS.LABELS.USER_NO_NAME) +
|
|
77
|
+
(user.userId === currentUser?.userId ? STRINGS.GROUP_CHANNEL_MEMBERS.USER_BAR_ME_POSTFIX : '')
|
|
78
|
+
}
|
|
79
|
+
disabled={user.userId === currentUser?.userId}
|
|
80
|
+
// TODO: implement ban/mute actions, use channel.members with handlers instead member query
|
|
81
|
+
onPressActionMenu={undefined}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
[renderUser],
|
|
86
|
+
);
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
89
|
<UserListModule.Provider headerRight={noop} headerTitle={STRINGS.GROUP_CHANNEL_MEMBERS.HEADER_TITLE}>
|
package/src/hooks/useContext.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
|
|
3
|
-
import { LocalizationContext } from '../contexts/
|
|
4
|
-
import { PlatformServiceContext } from '../contexts/
|
|
5
|
-
import {
|
|
6
|
-
import { SendbirdChatContext } from '../contexts/SendbirdChatCtx';
|
|
3
|
+
import { LocalizationContext } from '../contexts/Localization';
|
|
4
|
+
import { PlatformServiceContext } from '../contexts/PlatformService';
|
|
5
|
+
import { SendbirdChatContext } from '../contexts/SendbirdChat';
|
|
7
6
|
|
|
8
7
|
export const useLocalization = () => {
|
|
9
8
|
const value = useContext(LocalizationContext);
|
|
@@ -22,9 +21,3 @@ export const useSendbirdChat = () => {
|
|
|
22
21
|
if (!value) throw new Error('SendbirdChatContext is not provided');
|
|
23
22
|
return value;
|
|
24
23
|
};
|
|
25
|
-
|
|
26
|
-
export const useProfileCard = () => {
|
|
27
|
-
const value = useContext(ProfileCardContext);
|
|
28
|
-
if (!value) throw new Error('ProfileCardContext is not provided');
|
|
29
|
-
return value;
|
|
30
|
-
};
|
package/src/index.ts
CHANGED
|
@@ -24,15 +24,14 @@ export { default as createGroupChannelListFragment } from './fragments/createGro
|
|
|
24
24
|
export { default as createGroupChannelMembersFragment } from './fragments/createGroupChannelMembersFragment';
|
|
25
25
|
|
|
26
26
|
/** Context **/
|
|
27
|
-
export { SendbirdChatContext, SendbirdChatProvider } from './contexts/
|
|
28
|
-
export { PlatformServiceContext, PlatformServiceProvider } from './contexts/
|
|
29
|
-
export {
|
|
30
|
-
export { LocalizationContext, LocalizationProvider } from './contexts/LocalizationCtx';
|
|
27
|
+
export { SendbirdChatContext, SendbirdChatProvider } from './contexts/SendbirdChat';
|
|
28
|
+
export { PlatformServiceContext, PlatformServiceProvider } from './contexts/PlatformService';
|
|
29
|
+
export { LocalizationContext, LocalizationProvider } from './contexts/Localization';
|
|
31
30
|
|
|
32
31
|
/** Hooks **/
|
|
33
32
|
export { default as useConnection } from './hooks/useConnection';
|
|
34
33
|
export { default as usePushTokenRegistration } from './hooks/usePushTokenRegistration';
|
|
35
|
-
export { useLocalization, usePlatformService, useSendbirdChat
|
|
34
|
+
export { useLocalization, usePlatformService, useSendbirdChat } from './hooks/useContext';
|
|
36
35
|
|
|
37
36
|
/** Localization **/
|
|
38
37
|
export { default as StringSetEn } from './localization/StringSet.en';
|
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
PartialDeep,
|
|
5
5
|
SendbirdFileMessage,
|
|
6
6
|
SendbirdGroupChannel,
|
|
7
|
-
SendbirdMember,
|
|
8
7
|
SendbirdMessage,
|
|
9
8
|
SendbirdUser,
|
|
10
9
|
} from '@sendbird/uikit-utils';
|
|
@@ -175,11 +174,6 @@ export interface StringSet {
|
|
|
175
174
|
TURN_OFF_NOTIFICATIONS_ERROR: string;
|
|
176
175
|
LEAVE_CHANNEL_ERROR: string;
|
|
177
176
|
};
|
|
178
|
-
PROFILE_CARD: {
|
|
179
|
-
BUTTON_MESSAGE: string;
|
|
180
|
-
BODY_LABEL: string;
|
|
181
|
-
BODY: (user: SendbirdUser | SendbirdMember) => string;
|
|
182
|
-
};
|
|
183
177
|
}
|
|
184
178
|
|
|
185
179
|
type StringSetCreateOptions = {
|
|
@@ -354,11 +348,5 @@ export const createBaseStringSet = ({ dateLocale, overrides }: StringSetCreateOp
|
|
|
354
348
|
LEAVE_CHANNEL_ERROR: "Couldn't leave channel.",
|
|
355
349
|
...overrides?.TOAST,
|
|
356
350
|
},
|
|
357
|
-
PROFILE_CARD: {
|
|
358
|
-
BUTTON_MESSAGE: 'Message',
|
|
359
|
-
BODY_LABEL: 'User ID',
|
|
360
|
-
BODY: (user) => user.userId,
|
|
361
|
-
...overrides?.PROFILE_CARD,
|
|
362
|
-
},
|
|
363
351
|
};
|
|
364
352
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type CameraRoll from '@react-native-community/cameraroll';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import type * as DocumentPicker from 'react-native-document-picker';
|
|
4
4
|
import type * as FileAccess from 'react-native-file-access';
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const VERSION = '2.0.
|
|
1
|
+
const VERSION = '2.0.3';
|
|
2
2
|
export default VERSION;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["LocalizationContext","React","createContext","LocalizationProvider","children","stringSet","STRINGS"],"sources":["LocalizationCtx.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { StringSet } from '../localization/StringSet.type';\n\ntype Props = React.PropsWithChildren<{\n stringSet: StringSet;\n}>;\n\nexport type LocalizationContextType = {\n STRINGS: StringSet;\n};\n\nexport const LocalizationContext = React.createContext<LocalizationContextType | null>(null);\nexport const LocalizationProvider = ({ children, stringSet }: Props) => {\n return <LocalizationContext.Provider value={{ STRINGS: stringSet }}>{children}</LocalizationContext.Provider>;\n};\n"],"mappings":";;;;;;;AAAA;;;;AAYO,MAAMA,mBAAmB,gBAAGC,cAAA,CAAMC,aAAN,CAAoD,IAApD,CAA5B;;;;AACA,MAAMC,oBAAoB,GAAG,QAAoC;EAAA,IAAnC;IAAEC,QAAF;IAAYC;EAAZ,CAAmC;EACtE,oBAAO,6BAAC,mBAAD,CAAqB,QAArB;IAA8B,KAAK,EAAE;MAAEC,OAAO,EAAED;IAAX;EAArC,GAA8DD,QAA9D,CAAP;AACD,CAFM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["PlatformServiceContext","React","createContext","PlatformServiceProvider","children","fileService","clipboardService","notificationService","mediaService"],"sources":["PlatformServiceCtx.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {\n ClipboardServiceInterface,\n FileServiceInterface,\n MediaServiceInterface,\n NotificationServiceInterface,\n} from '../platform/types';\n\ntype Props = React.PropsWithChildren<{\n fileService: FileServiceInterface;\n clipboardService: ClipboardServiceInterface;\n notificationService: NotificationServiceInterface;\n mediaService?: MediaServiceInterface;\n}>;\n\nexport const PlatformServiceContext = React.createContext<Props | null>(null);\nexport const PlatformServiceProvider = ({\n children,\n fileService,\n clipboardService,\n notificationService,\n mediaService,\n}: Props) => {\n return (\n <PlatformServiceContext.Provider value={{ fileService, clipboardService, notificationService, mediaService }}>\n {children}\n </PlatformServiceContext.Provider>\n );\n};\n"],"mappings":";;;;;;;AAAA;;;;AAgBO,MAAMA,sBAAsB,gBAAGC,cAAA,CAAMC,aAAN,CAAkC,IAAlC,CAA/B;;;;AACA,MAAMC,uBAAuB,GAAG,QAM1B;EAAA,IAN2B;IACtCC,QADsC;IAEtCC,WAFsC;IAGtCC,gBAHsC;IAItCC,mBAJsC;IAKtCC;EALsC,CAM3B;EACX,oBACE,6BAAC,sBAAD,CAAwB,QAAxB;IAAiC,KAAK,EAAE;MAAEH,WAAF;MAAeC,gBAAf;MAAiCC,mBAAjC;MAAsDC;IAAtD;EAAxC,GACGJ,QADH,CADF;AAKD,CAZM"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ProfileCardProvider = exports.ProfileCardContext = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
11
|
-
|
|
12
|
-
var _uikitReactNativeFoundation = require("@sendbird/uikit-react-native-foundation");
|
|
13
|
-
|
|
14
|
-
var _uikitUtils = require("@sendbird/uikit-utils");
|
|
15
|
-
|
|
16
|
-
var _LocalizationCtx = require("../contexts/LocalizationCtx");
|
|
17
|
-
|
|
18
|
-
var _SendbirdChatCtx = require("../contexts/SendbirdChatCtx");
|
|
19
|
-
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
|
-
const ProfileCardContext = /*#__PURE__*/_react.default.createContext(null);
|
|
25
|
-
|
|
26
|
-
exports.ProfileCardContext = ProfileCardContext;
|
|
27
|
-
|
|
28
|
-
const ProfileCardProvider = _ref => {
|
|
29
|
-
let {
|
|
30
|
-
children,
|
|
31
|
-
onCreateChannel,
|
|
32
|
-
onBeforeCreateChannel = _uikitUtils.PASS
|
|
33
|
-
} = _ref;
|
|
34
|
-
const chatContext = (0, _react.useContext)(_SendbirdChatCtx.SendbirdChatContext);
|
|
35
|
-
const localizationContext = (0, _react.useContext)(_LocalizationCtx.LocalizationContext);
|
|
36
|
-
const {
|
|
37
|
-
bottom,
|
|
38
|
-
left,
|
|
39
|
-
right
|
|
40
|
-
} = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
41
|
-
const [user, setUser] = (0, _react.useState)();
|
|
42
|
-
const [visible, setVisible] = (0, _react.useState)(false);
|
|
43
|
-
|
|
44
|
-
const show = user => {
|
|
45
|
-
setUser(user);
|
|
46
|
-
setVisible(true);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const hide = () => {
|
|
50
|
-
setVisible(false);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
if (!chatContext) throw new Error('SendbirdChatContext is not provided');
|
|
54
|
-
if (!localizationContext) throw new Error('LocalizationContext is not provided');
|
|
55
|
-
const profileCardButton = (0, _uikitUtils.useIIFE)(() => {
|
|
56
|
-
const isMe = chatContext.currentUser && (user === null || user === void 0 ? void 0 : user.userId) === chatContext.currentUser.userId;
|
|
57
|
-
if (isMe) return undefined;
|
|
58
|
-
|
|
59
|
-
const onPressMessageButton = async () => {
|
|
60
|
-
if (user) {
|
|
61
|
-
const params = {
|
|
62
|
-
invitedUserIds: [user.userId],
|
|
63
|
-
name: '',
|
|
64
|
-
coverUrl: '',
|
|
65
|
-
isDistinct: false
|
|
66
|
-
};
|
|
67
|
-
if (chatContext.currentUser) params.operatorUserIds = [chatContext.currentUser.userId];
|
|
68
|
-
const processedParams = await onBeforeCreateChannel(params, [user]);
|
|
69
|
-
hide();
|
|
70
|
-
const channel = await chatContext.sdk.groupChannel.createChannel(processedParams);
|
|
71
|
-
|
|
72
|
-
if (onCreateChannel) {
|
|
73
|
-
onCreateChannel(channel);
|
|
74
|
-
} else {
|
|
75
|
-
_uikitUtils.Logger.warn('Please set `onCreateChannel` before message to user from profile card, see `profileCard` prop in the `SendbirdUIKitContainer` props');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
return /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.OutlinedButton, {
|
|
81
|
-
onPress: onPressMessageButton
|
|
82
|
-
}, localizationContext.STRINGS.PROFILE_CARD.BUTTON_MESSAGE);
|
|
83
|
-
});
|
|
84
|
-
return /*#__PURE__*/_react.default.createElement(ProfileCardContext.Provider, {
|
|
85
|
-
value: {
|
|
86
|
-
show,
|
|
87
|
-
hide
|
|
88
|
-
}
|
|
89
|
-
}, children, /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.Modal, {
|
|
90
|
-
type: 'slide',
|
|
91
|
-
onClose: hide,
|
|
92
|
-
onDismiss: () => setUser(undefined),
|
|
93
|
-
visible: visible && Boolean(user),
|
|
94
|
-
backgroundStyle: styles.modal
|
|
95
|
-
}, user && /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.ProfileCard, {
|
|
96
|
-
containerStyle: [styles.profileCardContainer, {
|
|
97
|
-
paddingLeft: left,
|
|
98
|
-
paddingRight: right,
|
|
99
|
-
paddingBottom: bottom
|
|
100
|
-
}],
|
|
101
|
-
uri: user.profileUrl,
|
|
102
|
-
username: user.nickname || localizationContext.STRINGS.LABELS.USER_NO_NAME,
|
|
103
|
-
bodyLabel: localizationContext.STRINGS.PROFILE_CARD.BODY_LABEL,
|
|
104
|
-
body: localizationContext.STRINGS.PROFILE_CARD.BODY(user),
|
|
105
|
-
button: profileCardButton
|
|
106
|
-
})));
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
exports.ProfileCardProvider = ProfileCardProvider;
|
|
110
|
-
const styles = (0, _uikitReactNativeFoundation.createStyleSheet)({
|
|
111
|
-
modal: {
|
|
112
|
-
justifyContent: 'flex-end'
|
|
113
|
-
},
|
|
114
|
-
profileCardContainer: {
|
|
115
|
-
borderTopLeftRadius: 8,
|
|
116
|
-
borderTopRightRadius: 8
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
//# sourceMappingURL=ProfileCardCtx.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ProfileCardContext","React","createContext","ProfileCardProvider","children","onCreateChannel","onBeforeCreateChannel","PASS","chatContext","useContext","SendbirdChatContext","localizationContext","LocalizationContext","bottom","left","right","useSafeAreaInsets","user","setUser","useState","visible","setVisible","show","hide","Error","profileCardButton","useIIFE","isMe","currentUser","userId","undefined","onPressMessageButton","params","invitedUserIds","name","coverUrl","isDistinct","operatorUserIds","processedParams","channel","sdk","groupChannel","createChannel","Logger","warn","STRINGS","PROFILE_CARD","BUTTON_MESSAGE","Boolean","styles","modal","profileCardContainer","paddingLeft","paddingRight","paddingBottom","profileUrl","nickname","LABELS","USER_NO_NAME","BODY_LABEL","BODY","createStyleSheet","justifyContent","borderTopLeftRadius","borderTopRightRadius"],"sources":["ProfileCardCtx.tsx"],"sourcesContent":["import React, { useContext, useState } from 'react';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport { Modal, OutlinedButton, ProfileCard, createStyleSheet } from '@sendbird/uikit-react-native-foundation';\nimport type {\n SendbirdGroupChannel,\n SendbirdGroupChannelCreateParams,\n SendbirdMember,\n SendbirdUser,\n} from '@sendbird/uikit-utils';\nimport { Logger, PASS, useIIFE } from '@sendbird/uikit-utils';\n\nimport { LocalizationContext } from '../contexts/LocalizationCtx';\nimport { SendbirdChatContext } from '../contexts/SendbirdChatCtx';\n\ntype OnCreateChannel = (channel: SendbirdGroupChannel) => void;\ntype OnBeforeCreateChannel = (\n channelParams: SendbirdGroupChannelCreateParams,\n users: SendbirdUser[] | SendbirdMember[],\n) => SendbirdGroupChannelCreateParams | Promise<SendbirdGroupChannelCreateParams>;\n\nexport type ProfileCardContextType = {\n show(user: SendbirdUser | SendbirdMember): void;\n hide(): void;\n};\n\ntype Props = React.PropsWithChildren<{\n onCreateChannel?: OnCreateChannel;\n onBeforeCreateChannel?: OnBeforeCreateChannel;\n}>;\n\nexport const ProfileCardContext = React.createContext<ProfileCardContextType | null>(null);\nexport const ProfileCardProvider = ({ children, onCreateChannel, onBeforeCreateChannel = PASS }: Props) => {\n const chatContext = useContext(SendbirdChatContext);\n const localizationContext = useContext(LocalizationContext);\n const { bottom, left, right } = useSafeAreaInsets();\n\n const [user, setUser] = useState<SendbirdUser | SendbirdMember>();\n const [visible, setVisible] = useState(false);\n\n const show: ProfileCardContextType['show'] = (user) => {\n setUser(user);\n setVisible(true);\n };\n\n const hide: ProfileCardContextType['hide'] = () => {\n setVisible(false);\n };\n\n if (!chatContext) throw new Error('SendbirdChatContext is not provided');\n if (!localizationContext) throw new Error('LocalizationContext is not provided');\n\n const profileCardButton = useIIFE(() => {\n const isMe = chatContext.currentUser && user?.userId === chatContext.currentUser.userId;\n if (isMe) return undefined;\n\n const onPressMessageButton = async () => {\n if (user) {\n const params: SendbirdGroupChannelCreateParams = {\n invitedUserIds: [user.userId],\n name: '',\n coverUrl: '',\n isDistinct: false,\n };\n\n if (chatContext.currentUser) params.operatorUserIds = [chatContext.currentUser.userId];\n const processedParams = await onBeforeCreateChannel(params, [user]);\n\n hide();\n const channel = await chatContext.sdk.groupChannel.createChannel(processedParams);\n\n if (onCreateChannel) {\n onCreateChannel(channel);\n } else {\n Logger.warn(\n 'Please set `onCreateChannel` before message to user from profile card, see `profileCard` prop in the `SendbirdUIKitContainer` props',\n );\n }\n }\n };\n\n return (\n <OutlinedButton onPress={onPressMessageButton}>\n {localizationContext.STRINGS.PROFILE_CARD.BUTTON_MESSAGE}\n </OutlinedButton>\n );\n });\n\n return (\n <ProfileCardContext.Provider value={{ show, hide }}>\n {children}\n <Modal\n type={'slide'}\n onClose={hide}\n onDismiss={() => setUser(undefined)}\n visible={visible && Boolean(user)}\n backgroundStyle={styles.modal}\n >\n {user && (\n <ProfileCard\n containerStyle={[\n styles.profileCardContainer,\n { paddingLeft: left, paddingRight: right, paddingBottom: bottom },\n ]}\n uri={user.profileUrl}\n username={user.nickname || localizationContext.STRINGS.LABELS.USER_NO_NAME}\n bodyLabel={localizationContext.STRINGS.PROFILE_CARD.BODY_LABEL}\n body={localizationContext.STRINGS.PROFILE_CARD.BODY(user)}\n button={profileCardButton}\n />\n )}\n </Modal>\n </ProfileCardContext.Provider>\n );\n};\n\nconst styles = createStyleSheet({\n modal: {\n justifyContent: 'flex-end',\n },\n profileCardContainer: {\n borderTopLeftRadius: 8,\n borderTopRightRadius: 8,\n },\n});\n"],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["SendbirdChatContext","React","createContext","SendbirdChatProvider","children","sdkInstance","enableAutoPushTokenRegistration","enableChannelListMessageReceiptStatus","enableChannelListTypingIndicator","currentUser","_setCurrentUser","useState","forceUpdate","useForceUpdate","appFeatures","useAppFeatures","setCurrentUser","useCallback","user","updateCurrentUserInfo","nickname","profile","Error","params","profileUrl","profileImage","markAsDeliveredWithChannel","channel","deliveryReceiptEnabled","confirmAndMarkAsDelivered","useEffect","listener","status","connectionState","setForegroundState","setBackgroundState","subscriber","AppState","addEventListener","remove","value","sdk","features","autoPushTokenRegistrationEnabled","channelListTypingIndicatorEnabled","channelListMessageReceiptStatusEnabled"],"sources":["SendbirdChatCtx.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport { AppState, AppStateStatus } from 'react-native';\n\nimport { useAppFeatures } from '@sendbird/uikit-chat-hooks';\nimport type {\n SendbirdChatSDK,\n SendbirdGroupChannel,\n SendbirdUser,\n SendbirdUserUpdateParams,\n} from '@sendbird/uikit-utils';\nimport { confirmAndMarkAsDelivered, useForceUpdate } from '@sendbird/uikit-utils';\n\nimport type { FileType } from '../platform/types';\n\ntype Props = React.PropsWithChildren<{\n sdkInstance: SendbirdChatSDK;\n\n enableAutoPushTokenRegistration: boolean;\n enableChannelListTypingIndicator: boolean;\n enableChannelListMessageReceiptStatus: boolean;\n}>;\n\ntype Context = {\n sdk: SendbirdChatSDK;\n currentUser?: SendbirdUser;\n setCurrentUser: React.Dispatch<React.SetStateAction<SendbirdUser | undefined>>;\n\n // helper functions\n updateCurrentUserInfo: (nickname?: string, profile?: string | FileType) => Promise<SendbirdUser>;\n markAsDeliveredWithChannel: (channel: SendbirdGroupChannel) => void;\n\n features: {\n // UIKit features\n autoPushTokenRegistrationEnabled: boolean;\n channelListTypingIndicatorEnabled: boolean;\n channelListMessageReceiptStatusEnabled: boolean;\n\n // Sendbird application features\n deliveryReceiptEnabled: boolean;\n broadcastChannelEnabled: boolean;\n superGroupChannelEnabled: boolean;\n reactionEnabled: boolean;\n };\n};\n\nexport const SendbirdChatContext = React.createContext<Context | null>(null);\nexport const SendbirdChatProvider = ({\n children,\n sdkInstance,\n enableAutoPushTokenRegistration,\n enableChannelListMessageReceiptStatus,\n enableChannelListTypingIndicator,\n}: Props) => {\n const [currentUser, _setCurrentUser] = useState<SendbirdUser>();\n const forceUpdate = useForceUpdate();\n const appFeatures = useAppFeatures(sdkInstance);\n\n const setCurrentUser: Context['setCurrentUser'] = useCallback((user) => {\n // NOTE: Sendbird SDK handle User object is always same object, so force update after setCurrentUser\n _setCurrentUser(user);\n forceUpdate();\n }, []);\n\n const updateCurrentUserInfo: Context['updateCurrentUserInfo'] = useCallback(\n async (nickname, profile) => {\n let user = currentUser;\n\n if (!user) throw new Error('Current user is not defined, please connect using `useConnection()` hook first');\n\n const params: SendbirdUserUpdateParams = { nickname };\n\n if (typeof profile === 'string') {\n params.profileUrl = profile;\n } else if (typeof profile === 'object') {\n params.profileImage = profile;\n } else {\n throw new Error(`Cannot update profile, not supported profile type(${typeof profile})`);\n }\n\n user = await sdkInstance.updateCurrentUserInfo(params);\n\n setCurrentUser(user);\n return user;\n },\n [sdkInstance, currentUser, setCurrentUser],\n );\n\n const markAsDeliveredWithChannel: Context['markAsDeliveredWithChannel'] = useCallback(\n (channel: SendbirdGroupChannel) => {\n if (appFeatures.deliveryReceiptEnabled) confirmAndMarkAsDelivered([channel]);\n },\n [sdkInstance, appFeatures.deliveryReceiptEnabled],\n );\n\n useEffect(() => {\n const listener = (status: AppStateStatus) => {\n // 'active' | 'background' | 'inactive' | 'unknown' | 'extension';\n if (status === 'active') sdkInstance.connectionState === 'CLOSED' && sdkInstance.setForegroundState();\n else if (status === 'background') sdkInstance.connectionState === 'OPEN' && sdkInstance.setBackgroundState();\n };\n\n const subscriber = AppState.addEventListener('change', listener);\n return () => subscriber.remove();\n }, [sdkInstance]);\n\n const value: Context = {\n sdk: sdkInstance,\n currentUser,\n setCurrentUser,\n\n updateCurrentUserInfo,\n markAsDeliveredWithChannel,\n\n features: {\n ...appFeatures,\n autoPushTokenRegistrationEnabled: enableAutoPushTokenRegistration,\n channelListTypingIndicatorEnabled: enableChannelListTypingIndicator,\n channelListMessageReceiptStatusEnabled: enableChannelListMessageReceiptStatus,\n },\n };\n\n return <SendbirdChatContext.Provider value={value}>{children}</SendbirdChatContext.Provider>;\n};\n"],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","LocalizationContext","createContext","LocalizationProvider","children","stringSet","STRINGS"],"sources":["LocalizationCtx.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { StringSet } from '../localization/StringSet.type';\n\ntype Props = React.PropsWithChildren<{\n stringSet: StringSet;\n}>;\n\nexport type LocalizationContextType = {\n STRINGS: StringSet;\n};\n\nexport const LocalizationContext = React.createContext<LocalizationContextType | null>(null);\nexport const LocalizationProvider = ({ children, stringSet }: Props) => {\n return <LocalizationContext.Provider value={{ STRINGS: stringSet }}>{children}</LocalizationContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAYA,OAAO,MAAMC,mBAAmB,gBAAGD,KAAK,CAACE,aAAN,CAAoD,IAApD,CAA5B;AACP,OAAO,MAAMC,oBAAoB,GAAG,QAAoC;EAAA,IAAnC;IAAEC,QAAF;IAAYC;EAAZ,CAAmC;EACtE,oBAAO,oBAAC,mBAAD,CAAqB,QAArB;IAA8B,KAAK,EAAE;MAAEC,OAAO,EAAED;IAAX;EAArC,GAA8DD,QAA9D,CAAP;AACD,CAFM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","PlatformServiceContext","createContext","PlatformServiceProvider","children","fileService","clipboardService","notificationService","mediaService"],"sources":["PlatformServiceCtx.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {\n ClipboardServiceInterface,\n FileServiceInterface,\n MediaServiceInterface,\n NotificationServiceInterface,\n} from '../platform/types';\n\ntype Props = React.PropsWithChildren<{\n fileService: FileServiceInterface;\n clipboardService: ClipboardServiceInterface;\n notificationService: NotificationServiceInterface;\n mediaService?: MediaServiceInterface;\n}>;\n\nexport const PlatformServiceContext = React.createContext<Props | null>(null);\nexport const PlatformServiceProvider = ({\n children,\n fileService,\n clipboardService,\n notificationService,\n mediaService,\n}: Props) => {\n return (\n <PlatformServiceContext.Provider value={{ fileService, clipboardService, notificationService, mediaService }}>\n {children}\n </PlatformServiceContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAgBA,OAAO,MAAMC,sBAAsB,gBAAGD,KAAK,CAACE,aAAN,CAAkC,IAAlC,CAA/B;AACP,OAAO,MAAMC,uBAAuB,GAAG,QAM1B;EAAA,IAN2B;IACtCC,QADsC;IAEtCC,WAFsC;IAGtCC,gBAHsC;IAItCC,mBAJsC;IAKtCC;EALsC,CAM3B;EACX,oBACE,oBAAC,sBAAD,CAAwB,QAAxB;IAAiC,KAAK,EAAE;MAAEH,WAAF;MAAeC,gBAAf;MAAiCC,mBAAjC;MAAsDC;IAAtD;EAAxC,GACGJ,QADH,CADF;AAKD,CAZM"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useState } from 'react';
|
|
2
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
3
|
-
import { Modal, OutlinedButton, ProfileCard, createStyleSheet } from '@sendbird/uikit-react-native-foundation';
|
|
4
|
-
import { Logger, PASS, useIIFE } from '@sendbird/uikit-utils';
|
|
5
|
-
import { LocalizationContext } from '../contexts/LocalizationCtx';
|
|
6
|
-
import { SendbirdChatContext } from '../contexts/SendbirdChatCtx';
|
|
7
|
-
export const ProfileCardContext = /*#__PURE__*/React.createContext(null);
|
|
8
|
-
export const ProfileCardProvider = _ref => {
|
|
9
|
-
let {
|
|
10
|
-
children,
|
|
11
|
-
onCreateChannel,
|
|
12
|
-
onBeforeCreateChannel = PASS
|
|
13
|
-
} = _ref;
|
|
14
|
-
const chatContext = useContext(SendbirdChatContext);
|
|
15
|
-
const localizationContext = useContext(LocalizationContext);
|
|
16
|
-
const {
|
|
17
|
-
bottom,
|
|
18
|
-
left,
|
|
19
|
-
right
|
|
20
|
-
} = useSafeAreaInsets();
|
|
21
|
-
const [user, setUser] = useState();
|
|
22
|
-
const [visible, setVisible] = useState(false);
|
|
23
|
-
|
|
24
|
-
const show = user => {
|
|
25
|
-
setUser(user);
|
|
26
|
-
setVisible(true);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const hide = () => {
|
|
30
|
-
setVisible(false);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
if (!chatContext) throw new Error('SendbirdChatContext is not provided');
|
|
34
|
-
if (!localizationContext) throw new Error('LocalizationContext is not provided');
|
|
35
|
-
const profileCardButton = useIIFE(() => {
|
|
36
|
-
const isMe = chatContext.currentUser && (user === null || user === void 0 ? void 0 : user.userId) === chatContext.currentUser.userId;
|
|
37
|
-
if (isMe) return undefined;
|
|
38
|
-
|
|
39
|
-
const onPressMessageButton = async () => {
|
|
40
|
-
if (user) {
|
|
41
|
-
const params = {
|
|
42
|
-
invitedUserIds: [user.userId],
|
|
43
|
-
name: '',
|
|
44
|
-
coverUrl: '',
|
|
45
|
-
isDistinct: false
|
|
46
|
-
};
|
|
47
|
-
if (chatContext.currentUser) params.operatorUserIds = [chatContext.currentUser.userId];
|
|
48
|
-
const processedParams = await onBeforeCreateChannel(params, [user]);
|
|
49
|
-
hide();
|
|
50
|
-
const channel = await chatContext.sdk.groupChannel.createChannel(processedParams);
|
|
51
|
-
|
|
52
|
-
if (onCreateChannel) {
|
|
53
|
-
onCreateChannel(channel);
|
|
54
|
-
} else {
|
|
55
|
-
Logger.warn('Please set `onCreateChannel` before message to user from profile card, see `profileCard` prop in the `SendbirdUIKitContainer` props');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return /*#__PURE__*/React.createElement(OutlinedButton, {
|
|
61
|
-
onPress: onPressMessageButton
|
|
62
|
-
}, localizationContext.STRINGS.PROFILE_CARD.BUTTON_MESSAGE);
|
|
63
|
-
});
|
|
64
|
-
return /*#__PURE__*/React.createElement(ProfileCardContext.Provider, {
|
|
65
|
-
value: {
|
|
66
|
-
show,
|
|
67
|
-
hide
|
|
68
|
-
}
|
|
69
|
-
}, children, /*#__PURE__*/React.createElement(Modal, {
|
|
70
|
-
type: 'slide',
|
|
71
|
-
onClose: hide,
|
|
72
|
-
onDismiss: () => setUser(undefined),
|
|
73
|
-
visible: visible && Boolean(user),
|
|
74
|
-
backgroundStyle: styles.modal
|
|
75
|
-
}, user && /*#__PURE__*/React.createElement(ProfileCard, {
|
|
76
|
-
containerStyle: [styles.profileCardContainer, {
|
|
77
|
-
paddingLeft: left,
|
|
78
|
-
paddingRight: right,
|
|
79
|
-
paddingBottom: bottom
|
|
80
|
-
}],
|
|
81
|
-
uri: user.profileUrl,
|
|
82
|
-
username: user.nickname || localizationContext.STRINGS.LABELS.USER_NO_NAME,
|
|
83
|
-
bodyLabel: localizationContext.STRINGS.PROFILE_CARD.BODY_LABEL,
|
|
84
|
-
body: localizationContext.STRINGS.PROFILE_CARD.BODY(user),
|
|
85
|
-
button: profileCardButton
|
|
86
|
-
})));
|
|
87
|
-
};
|
|
88
|
-
const styles = createStyleSheet({
|
|
89
|
-
modal: {
|
|
90
|
-
justifyContent: 'flex-end'
|
|
91
|
-
},
|
|
92
|
-
profileCardContainer: {
|
|
93
|
-
borderTopLeftRadius: 8,
|
|
94
|
-
borderTopRightRadius: 8
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
//# sourceMappingURL=ProfileCardCtx.js.map
|