@sendbird/uikit-react-native 3.6.0 → 3.7.1
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 +11 -27
- package/lib/commonjs/containers/SendbirdUIKitContainer.js +9 -11
- package/lib/commonjs/containers/SendbirdUIKitContainer.js.map +1 -1
- package/lib/commonjs/contexts/SendbirdChatCtx.js +1 -1
- package/lib/commonjs/contexts/SendbirdChatCtx.js.map +1 -1
- package/lib/commonjs/libs/EmojiManager.js.map +1 -1
- package/lib/commonjs/libs/InternalLocalCacheStorage.js +65 -19
- package/lib/commonjs/libs/InternalLocalCacheStorage.js.map +1 -1
- package/lib/commonjs/platform/createMediaService.native.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/containers/SendbirdUIKitContainer.js +10 -12
- package/lib/module/containers/SendbirdUIKitContainer.js.map +1 -1
- package/lib/module/contexts/SendbirdChatCtx.js +1 -1
- package/lib/module/contexts/SendbirdChatCtx.js.map +1 -1
- package/lib/module/libs/EmojiManager.js.map +1 -1
- package/lib/module/libs/InternalLocalCacheStorage.js +65 -19
- package/lib/module/libs/InternalLocalCacheStorage.js.map +1 -1
- package/lib/module/platform/createMediaService.native.js.map +1 -1
- package/lib/module/types.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 +7 -7
- package/lib/typescript/src/domain/openChannel/component/OpenChannelHeader.d.ts +1 -1
- package/lib/typescript/src/hooks/useChannelInputItems.d.ts +1 -1
- package/lib/typescript/src/libs/InternalLocalCacheStorage.d.ts +5 -4
- package/lib/typescript/src/types.d.ts +4 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +26 -21
- package/src/containers/SendbirdUIKitContainer.tsx +24 -14
- package/src/contexts/SendbirdChatCtx.tsx +1 -1
- package/src/libs/EmojiManager.ts +2 -2
- package/src/libs/InternalLocalCacheStorage.ts +70 -21
- package/src/platform/createMediaService.native.tsx +9 -1
- package/src/types.ts +6 -1
- package/src/version.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SendbirdChannel } from '@sendbird/uikit-utils';
|
|
2
2
|
import { FileType } from '../platform/types';
|
|
3
3
|
export declare const useChannelInputItems: (channel: SendbirdChannel, sendFileMessage: (file: FileType) => void) => {
|
|
4
|
-
icon?: "search" | "stop" | "photo" | "recording" | "message" | "done" | "user" | "add" | "chat-hide" | "chat-show" | "archive" | "arrow-left" | "audio-off-filled" | "audio-off" | "audio-on-filled" | "audio-on" | "ban" | "broadcast" | "camera" | "channels" | "chat-filled" | "chat" | "checkbox-off" | "checkbox-on" | "chevron-down" | "chevron-right" | "close" | "copy" | "create" | "
|
|
4
|
+
icon?: "search" | "stop" | "photo" | "recording" | "delete" | "message" | "done" | "user" | "add" | "chat-hide" | "chat-show" | "archive" | "arrow-left" | "audio-off-filled" | "audio-off" | "audio-on-filled" | "audio-on" | "ban" | "broadcast" | "camera" | "channels" | "chat-filled" | "chat" | "checkbox-off" | "checkbox-on" | "chevron-down" | "chevron-right" | "close" | "copy" | "create" | "document" | "done-all" | "download" | "edit" | "emoji-more" | "error" | "file-audio" | "file-document" | "freeze" | "gif" | "info" | "leave" | "members" | "moderation" | "more" | "mute" | "notifications-filled" | "notifications-off-filled" | "notifications" | "operator" | "pause" | "play" | "plus" | "question" | "radio-off" | "radio-on" | "refresh" | "remove" | "reply-filled" | "reply" | "send" | "settings-filled" | "spinner" | "streaming" | "supergroup" | "theme" | "thread" | "thumbnail-none" | "unarchive" | undefined;
|
|
5
5
|
iconColor?: string | undefined;
|
|
6
6
|
title: string;
|
|
7
7
|
titleColor?: string | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { KeyValuePairGet, KeyValuePairSet, LocalCacheStorage } from '../types';
|
|
2
|
-
export default class InternalLocalCacheStorage implements
|
|
3
|
-
private
|
|
1
|
+
import type { AsyncLocalCacheStorage, KeyValuePairGet, KeyValuePairSet, LocalCacheStorage } from '../types';
|
|
2
|
+
export default class InternalLocalCacheStorage implements AsyncLocalCacheStorage {
|
|
3
|
+
private readonly _mmkv?;
|
|
4
|
+
private readonly _async?;
|
|
4
5
|
constructor(storage: LocalCacheStorage);
|
|
5
|
-
getAllKeys(): Promise<readonly string[]
|
|
6
|
+
getAllKeys(): Promise<readonly string[]>;
|
|
6
7
|
getItem(key: string): Promise<string | null>;
|
|
7
8
|
removeItem(key: string): Promise<void>;
|
|
8
9
|
setItem(key: string, value: string): Promise<void>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ComponentType, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
import type { MMKV } from 'react-native-mmkv';
|
|
2
3
|
import type { SendbirdUser } from '@sendbird/uikit-utils';
|
|
4
|
+
export type LocalCacheStorage = AsyncLocalCacheStorage | MMKVLocalCacheStorage;
|
|
3
5
|
export type KeyValuePairGet = [string, string | null];
|
|
4
6
|
export type KeyValuePairSet = [string, string];
|
|
5
|
-
export interface
|
|
7
|
+
export interface AsyncLocalCacheStorage {
|
|
6
8
|
getAllKeys(): Promise<readonly string[] | string[]>;
|
|
7
9
|
getItem(key: string): Promise<string | null>;
|
|
8
10
|
setItem(key: string, value: string): Promise<void>;
|
|
@@ -11,6 +13,7 @@ export interface LocalCacheStorage {
|
|
|
11
13
|
multiGet?(keys: string[]): Promise<readonly KeyValuePairGet[] | KeyValuePairGet[]>;
|
|
12
14
|
multiRemove?(keys: string[]): Promise<void>;
|
|
13
15
|
}
|
|
16
|
+
export type MMKVLocalCacheStorage = Pick<MMKV, 'getString' | 'set' | 'delete' | 'getAllKeys'>;
|
|
14
17
|
export type ErrorBoundaryProps = {
|
|
15
18
|
error: Error;
|
|
16
19
|
errorInfo: ErrorInfo;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const VERSION = "3.
|
|
1
|
+
declare const VERSION = "3.7.1";
|
|
2
2
|
export default VERSION;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendbird/uikit-react-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.1",
|
|
4
4
|
"description": "Sendbird UIKit for React Native: A feature-rich and customizable chat UI kit with messaging, channel management, and user authentication.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sendbird",
|
|
@@ -60,22 +60,21 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@openspacelabs/react-native-zoomable-view": "^2.1.5",
|
|
63
|
-
"@sendbird/uikit-chat-hooks": "3.
|
|
64
|
-
"@sendbird/uikit-react-native-foundation": "3.
|
|
63
|
+
"@sendbird/uikit-chat-hooks": "3.7.1",
|
|
64
|
+
"@sendbird/uikit-react-native-foundation": "3.7.1",
|
|
65
65
|
"@sendbird/uikit-tools": "0.0.1-alpha.77",
|
|
66
|
-
"@sendbird/uikit-utils": "3.
|
|
66
|
+
"@sendbird/uikit-utils": "3.7.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@bam.tech/react-native-image-resizer": "^3.0.4",
|
|
70
|
-
"@react-native-
|
|
71
|
-
"@react-native-
|
|
72
|
-
"@react-native-
|
|
70
|
+
"@react-native-async-storage/async-storage": "^1.17.6",
|
|
71
|
+
"@react-native-camera-roll/camera-roll": "^7.8.1",
|
|
72
|
+
"@react-native-clipboard/clipboard": "^1.14.1",
|
|
73
|
+
"@react-native-community/netinfo": "^11.3.2",
|
|
73
74
|
"@react-native-firebase/app": "^14.4.0",
|
|
74
75
|
"@react-native-firebase/messaging": "^14.4.0",
|
|
75
|
-
"@sendbird/react-native-scrollview-enhancer": "^0.2.1",
|
|
76
76
|
"@types/react": "*",
|
|
77
77
|
"@types/react-native": "*",
|
|
78
|
-
"@types/react-native-video": "^5.0.14",
|
|
79
78
|
"date-fns": "^2.28.0",
|
|
80
79
|
"expo-av": "^13.2.1",
|
|
81
80
|
"expo-clipboard": "^4.1.2",
|
|
@@ -89,26 +88,28 @@
|
|
|
89
88
|
"glob": "^7.2.0",
|
|
90
89
|
"inquirer": "^8.2.0",
|
|
91
90
|
"js-convert-case": "^4.2.0",
|
|
92
|
-
"react": "
|
|
93
|
-
"react-native": "0.
|
|
94
|
-
"react-native-audio-recorder-player": "^3.6.
|
|
91
|
+
"react": "18.2.0",
|
|
92
|
+
"react-native": "0.74.3",
|
|
93
|
+
"react-native-audio-recorder-player": "^3.6.10",
|
|
95
94
|
"react-native-builder-bob": "^0.18.0",
|
|
96
|
-
"react-native-create-thumbnail": "^
|
|
97
|
-
"react-native-document-picker": "^
|
|
98
|
-
"react-native-file-access": "^
|
|
99
|
-
"react-native-image-picker": "^
|
|
100
|
-
"react-native-
|
|
101
|
-
"react-native-
|
|
102
|
-
"react-native-
|
|
95
|
+
"react-native-create-thumbnail": "^2.0.0",
|
|
96
|
+
"react-native-document-picker": "^9.3.0",
|
|
97
|
+
"react-native-file-access": "^3.1.0",
|
|
98
|
+
"react-native-image-picker": "^7.1.2",
|
|
99
|
+
"react-native-mmkv": "^2.12.2",
|
|
100
|
+
"react-native-permissions": "^3.10.1",
|
|
101
|
+
"react-native-safe-area-context": "^4.10.8",
|
|
102
|
+
"react-native-video": "^6.3.0",
|
|
103
103
|
"typescript": "5.2.2"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"@bam.tech/react-native-image-resizer": ">=3.0.0",
|
|
107
|
+
"@react-native-async-storage/async-storage": "^1.17.6",
|
|
107
108
|
"@react-native-camera-roll/camera-roll": ">=5.0.0",
|
|
108
109
|
"@react-native-clipboard/clipboard": ">=1.8.5",
|
|
109
110
|
"@react-native-community/netinfo": ">=9.3.0",
|
|
110
111
|
"@react-native-firebase/messaging": ">=14.4.0",
|
|
111
|
-
"@sendbird/chat": "^4.
|
|
112
|
+
"@sendbird/chat": "^4.12.9",
|
|
112
113
|
"@sendbird/react-native-scrollview-enhancer": "*",
|
|
113
114
|
"date-fns": ">=2.28.0",
|
|
114
115
|
"expo-av": ">=12.0.4",
|
|
@@ -126,6 +127,7 @@
|
|
|
126
127
|
"react-native-document-picker": ">=8.0.0",
|
|
127
128
|
"react-native-file-access": ">=2.4.3",
|
|
128
129
|
"react-native-image-picker": ">=4.7.1",
|
|
130
|
+
"react-native-mmkv": "^2.0.0",
|
|
129
131
|
"react-native-permissions": ">=3.6.0",
|
|
130
132
|
"react-native-safe-area-context": ">=3.3.2",
|
|
131
133
|
"react-native-video": ">=5.2.0"
|
|
@@ -134,6 +136,9 @@
|
|
|
134
136
|
"@bam.tech/react-native-image-resizer": {
|
|
135
137
|
"optional": true
|
|
136
138
|
},
|
|
139
|
+
"@react-native-async-storage/async-storage": {
|
|
140
|
+
"optional": true
|
|
141
|
+
},
|
|
137
142
|
"@react-native-camera-roll/camera-roll": {
|
|
138
143
|
"optional": true
|
|
139
144
|
},
|
|
@@ -203,5 +208,5 @@
|
|
|
203
208
|
]
|
|
204
209
|
]
|
|
205
210
|
},
|
|
206
|
-
"gitHead": "
|
|
211
|
+
"gitHead": "9d1b5148c4af415c985566bddb45a20c97b365fd"
|
|
207
212
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { AsyncStorageStatic } from '@react-native-async-storage/async-storage';
|
|
1
2
|
import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
2
3
|
import { Platform } from 'react-native';
|
|
4
|
+
import type { MMKV } from 'react-native-mmkv';
|
|
3
5
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
4
6
|
|
|
5
7
|
import SendbirdChat, { DeviceOsPlatform, SendbirdChatParams, SendbirdPlatform, SendbirdProduct } from '@sendbird/chat';
|
|
@@ -15,15 +17,17 @@ import {
|
|
|
15
17
|
UIKitThemeProvider,
|
|
16
18
|
} from '@sendbird/uikit-react-native-foundation';
|
|
17
19
|
import { SBUConfig, UIKitConfigProvider } from '@sendbird/uikit-tools';
|
|
18
|
-
import
|
|
20
|
+
import {
|
|
21
|
+
Logger,
|
|
22
|
+
NOOP,
|
|
19
23
|
PartialDeep,
|
|
20
24
|
SendbirdChatSDK,
|
|
21
25
|
SendbirdGroupChannel,
|
|
22
26
|
SendbirdGroupChannelCreateParams,
|
|
23
27
|
SendbirdMember,
|
|
24
28
|
SendbirdUser,
|
|
29
|
+
useIsFirstMount,
|
|
25
30
|
} from '@sendbird/uikit-utils';
|
|
26
|
-
import { NOOP, useIsFirstMount } from '@sendbird/uikit-utils';
|
|
27
31
|
|
|
28
32
|
import { LocalizationContext, LocalizationProvider } from '../contexts/LocalizationCtx';
|
|
29
33
|
import { PlatformServiceProvider } from '../contexts/PlatformServiceCtx';
|
|
@@ -50,7 +54,7 @@ import type {
|
|
|
50
54
|
PlayerServiceInterface,
|
|
51
55
|
RecorderServiceInterface,
|
|
52
56
|
} from '../platform/types';
|
|
53
|
-
import
|
|
57
|
+
import { ErrorBoundaryProps, LocalCacheStorage } from '../types';
|
|
54
58
|
import VERSION from '../version';
|
|
55
59
|
import InternalErrorBoundaryContainer from './InternalErrorBoundaryContainer';
|
|
56
60
|
|
|
@@ -78,13 +82,13 @@ const chatOmitKeys = [
|
|
|
78
82
|
'appVersion',
|
|
79
83
|
'localCacheEnabled',
|
|
80
84
|
'useAsyncStorageStore',
|
|
85
|
+
'useMMKVStorageStore',
|
|
81
86
|
] as const;
|
|
82
87
|
function sanitizeChatOptions<T extends Record<string, unknown>>(chatOptions: T): T {
|
|
83
88
|
const opts = { ...chatOptions };
|
|
84
89
|
chatOmitKeys.forEach((key) => delete opts[key]);
|
|
85
90
|
return opts;
|
|
86
91
|
}
|
|
87
|
-
|
|
88
92
|
export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
|
|
89
93
|
appId: string;
|
|
90
94
|
platformServices: {
|
|
@@ -95,11 +99,11 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
|
|
|
95
99
|
player: PlayerServiceInterface;
|
|
96
100
|
recorder: RecorderServiceInterface;
|
|
97
101
|
};
|
|
98
|
-
chatOptions:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
chatOptions: Partial<ChatOmittedInitParams> &
|
|
103
|
+
Partial<ChatRelatedFeaturesInUIKit> & {
|
|
104
|
+
onInitialized?: (sdkInstance: SendbirdChatSDK) => SendbirdChatSDK;
|
|
105
|
+
localCacheStorage: LocalCacheStorage;
|
|
106
|
+
};
|
|
103
107
|
uikitOptions?: PartialDeep<{
|
|
104
108
|
common: SBUConfig['common'];
|
|
105
109
|
groupChannel: Omit<SBUConfig['groupChannel']['channel'], 'enableReactionsSupergroup'> & {
|
|
@@ -162,6 +166,10 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
|
|
|
162
166
|
|
|
163
167
|
if (!chatOptions.localCacheStorage) {
|
|
164
168
|
throw new Error('SendbirdUIKitContainer: chatOptions.localCacheStorage is required');
|
|
169
|
+
} else if ('getItem' in chatOptions.localCacheStorage) {
|
|
170
|
+
Logger.warn(
|
|
171
|
+
'SendbirdUIKitContainer: localCacheStorage for `AsyncStorage` is deprecated. Please use `MMKV` instead.',
|
|
172
|
+
);
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
const defaultStringSet = localization?.stringSet ?? StringSetEn;
|
|
@@ -171,7 +179,7 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
|
|
|
171
179
|
|
|
172
180
|
const [internalStorage] = useState(() => new InternalLocalCacheStorage(chatOptions.localCacheStorage));
|
|
173
181
|
const [sdkInstance, setSdkInstance] = useState<SendbirdChatSDK>(() => {
|
|
174
|
-
const sendbird = initializeSendbird(appId,
|
|
182
|
+
const sendbird = initializeSendbird(appId, sanitizeChatOptions(chatOptions));
|
|
175
183
|
unsubscribes.current = sendbird.unsubscribes;
|
|
176
184
|
return sendbird.chatSDK;
|
|
177
185
|
});
|
|
@@ -183,7 +191,7 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
|
|
|
183
191
|
|
|
184
192
|
useLayoutEffect(() => {
|
|
185
193
|
if (!isFirstMount) {
|
|
186
|
-
const sendbird = initializeSendbird(appId,
|
|
194
|
+
const sendbird = initializeSendbird(appId, sanitizeChatOptions(chatOptions));
|
|
187
195
|
setSdkInstance(sendbird.chatSDK);
|
|
188
196
|
unsubscribes.current = sendbird.unsubscribes;
|
|
189
197
|
}
|
|
@@ -288,21 +296,23 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
|
|
|
288
296
|
};
|
|
289
297
|
|
|
290
298
|
interface InitOptions extends ChatOmittedInitParams {
|
|
291
|
-
|
|
299
|
+
localCacheStorage: LocalCacheStorage;
|
|
292
300
|
onInitialized?: (sdk: SendbirdChatSDK) => SendbirdChatSDK;
|
|
293
301
|
}
|
|
294
302
|
const initializeSendbird = (appId: string, options: InitOptions) => {
|
|
295
303
|
let chatSDK: SendbirdChatSDK;
|
|
296
304
|
const unsubscribes: Array<() => void> = [];
|
|
297
|
-
const {
|
|
305
|
+
const { localCacheStorage, onInitialized, ...chatInitParams } = options;
|
|
298
306
|
|
|
307
|
+
const isMMKVStorage = 'getString' in localCacheStorage;
|
|
299
308
|
chatSDK = SendbirdChat.init({
|
|
300
309
|
...chatInitParams,
|
|
301
310
|
appId,
|
|
302
311
|
newInstance: true,
|
|
303
312
|
modules: [new GroupChannelModule(), new OpenChannelModule()],
|
|
304
313
|
localCacheEnabled: true,
|
|
305
|
-
|
|
314
|
+
useMMKVStorageStore: isMMKVStorage ? (localCacheStorage as MMKV) : undefined,
|
|
315
|
+
useAsyncStorageStore: !isMMKVStorage ? (localCacheStorage as AsyncStorageStatic) : undefined,
|
|
306
316
|
});
|
|
307
317
|
|
|
308
318
|
if (onInitialized) {
|
|
@@ -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
|
|
package/src/libs/EmojiManager.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { SendbirdEmoji, SendbirdEmojiCategory, SendbirdEmojiContainer } from '@sendbird/uikit-utils';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { AsyncLocalCacheStorage } from '../types';
|
|
4
4
|
import InternalLocalCacheStorage from './InternalLocalCacheStorage';
|
|
5
5
|
|
|
6
|
-
class MemoryStorage implements
|
|
6
|
+
class MemoryStorage implements AsyncLocalCacheStorage {
|
|
7
7
|
_data: Record<string, string> = {};
|
|
8
8
|
|
|
9
9
|
async getAllKeys(): Promise<readonly string[] | string[]> {
|
|
@@ -1,47 +1,96 @@
|
|
|
1
1
|
import { ASYNC_NOOP } from '@sendbird/uikit-utils';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
AsyncLocalCacheStorage,
|
|
5
|
+
KeyValuePairGet,
|
|
6
|
+
KeyValuePairSet,
|
|
7
|
+
LocalCacheStorage,
|
|
8
|
+
MMKVLocalCacheStorage,
|
|
9
|
+
} from '../types';
|
|
4
10
|
|
|
5
|
-
export default class InternalLocalCacheStorage implements
|
|
6
|
-
|
|
11
|
+
export default class InternalLocalCacheStorage implements AsyncLocalCacheStorage {
|
|
12
|
+
private readonly _mmkv?: MMKVLocalCacheStorage;
|
|
13
|
+
private readonly _async?: AsyncLocalCacheStorage;
|
|
7
14
|
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
constructor(storage: LocalCacheStorage) {
|
|
16
|
+
if ('getString' in storage) {
|
|
17
|
+
this._mmkv = storage;
|
|
18
|
+
} else {
|
|
19
|
+
this._async = storage;
|
|
20
|
+
}
|
|
10
21
|
}
|
|
11
22
|
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
async getAllKeys() {
|
|
24
|
+
if (this._mmkv) {
|
|
25
|
+
return this._mmkv.getAllKeys();
|
|
26
|
+
} else if (this._async) {
|
|
27
|
+
return this._async.getAllKeys();
|
|
28
|
+
} else {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async getItem(key: string) {
|
|
34
|
+
if (this._mmkv) {
|
|
35
|
+
return this._mmkv.getString(key) ?? null;
|
|
36
|
+
} else if (this._async) {
|
|
37
|
+
return this._async.getItem(key);
|
|
38
|
+
} else {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
14
41
|
}
|
|
15
42
|
|
|
16
|
-
removeItem(key: string) {
|
|
17
|
-
|
|
43
|
+
async removeItem(key: string) {
|
|
44
|
+
if (this._mmkv) {
|
|
45
|
+
this._mmkv.delete(key);
|
|
46
|
+
} else if (this._async) {
|
|
47
|
+
return this._async.removeItem(key);
|
|
48
|
+
}
|
|
18
49
|
}
|
|
19
50
|
|
|
20
|
-
setItem(key: string, value: string) {
|
|
21
|
-
|
|
51
|
+
async setItem(key: string, value: string) {
|
|
52
|
+
if (this._mmkv) {
|
|
53
|
+
this._mmkv.set(key, value);
|
|
54
|
+
} else if (this._async) {
|
|
55
|
+
return this._async.setItem(key, value);
|
|
56
|
+
}
|
|
22
57
|
}
|
|
23
58
|
|
|
24
59
|
async multiGet(keys: string[]) {
|
|
25
|
-
if (this.
|
|
26
|
-
return this.storage.multiGet(keys);
|
|
27
|
-
} else {
|
|
60
|
+
if (this._mmkv) {
|
|
28
61
|
return Promise.all(keys.map(async (key) => [key, await this.getItem(key)] as KeyValuePairGet));
|
|
62
|
+
} else if (this._async) {
|
|
63
|
+
if (this._async?.multiGet) {
|
|
64
|
+
return this._async.multiGet(keys);
|
|
65
|
+
} else {
|
|
66
|
+
return Promise.all(keys.map(async (key) => [key, await this.getItem(key)] as KeyValuePairGet));
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
return [];
|
|
29
70
|
}
|
|
30
71
|
}
|
|
31
72
|
|
|
32
73
|
async multiRemove(keys: string[]) {
|
|
33
|
-
if (this.
|
|
34
|
-
await this.storage.multiRemove(keys);
|
|
35
|
-
} else {
|
|
74
|
+
if (this._mmkv) {
|
|
36
75
|
await Promise.all(keys.map(async (key) => this.removeItem(key)));
|
|
76
|
+
} else if (this._async) {
|
|
77
|
+
if (this._async?.multiRemove) {
|
|
78
|
+
await this._async.multiRemove(keys);
|
|
79
|
+
} else {
|
|
80
|
+
await Promise.all(keys.map(async (key) => this.removeItem(key)));
|
|
81
|
+
}
|
|
37
82
|
}
|
|
38
83
|
}
|
|
39
84
|
|
|
40
85
|
async multiSet(keyValuePairs: Array<KeyValuePairSet>) {
|
|
41
|
-
if (this.
|
|
42
|
-
await
|
|
43
|
-
} else {
|
|
44
|
-
|
|
86
|
+
if (this._mmkv) {
|
|
87
|
+
await Promise.all(keyValuePairs.map(([key, value]) => this.setItem(key, value)));
|
|
88
|
+
} else if (this._async) {
|
|
89
|
+
if (this._async?.multiSet) {
|
|
90
|
+
await this._async.multiSet(keyValuePairs);
|
|
91
|
+
} else {
|
|
92
|
+
await Promise.all(keyValuePairs.map(([key, value]) => this.setItem(key, value)));
|
|
93
|
+
}
|
|
45
94
|
}
|
|
46
95
|
}
|
|
47
96
|
|
|
@@ -21,7 +21,15 @@ const createNativeMediaService = ({
|
|
|
21
21
|
}: Modules): MediaServiceInterface => {
|
|
22
22
|
return {
|
|
23
23
|
VideoComponent({ source, resizeMode, onLoad, ...props }) {
|
|
24
|
-
return
|
|
24
|
+
return (
|
|
25
|
+
<VideoComponent
|
|
26
|
+
{...props}
|
|
27
|
+
source={source as { uri: string }}
|
|
28
|
+
resizeMode={resizeMode}
|
|
29
|
+
onLoad={onLoad}
|
|
30
|
+
controls
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
25
33
|
},
|
|
26
34
|
async getVideoThumbnail({ url, timeMills }) {
|
|
27
35
|
try {
|
package/src/types.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { ComponentType, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
import type { MMKV } from 'react-native-mmkv';
|
|
2
3
|
|
|
3
4
|
import type { SendbirdUser } from '@sendbird/uikit-utils';
|
|
4
5
|
|
|
6
|
+
export type LocalCacheStorage = AsyncLocalCacheStorage | MMKVLocalCacheStorage;
|
|
7
|
+
|
|
5
8
|
export type KeyValuePairGet = [string, string | null];
|
|
6
9
|
export type KeyValuePairSet = [string, string];
|
|
7
|
-
export interface
|
|
10
|
+
export interface AsyncLocalCacheStorage {
|
|
8
11
|
getAllKeys(): Promise<readonly string[] | string[]>;
|
|
9
12
|
getItem(key: string): Promise<string | null>;
|
|
10
13
|
setItem(key: string, value: string): Promise<void>;
|
|
@@ -15,6 +18,8 @@ export interface LocalCacheStorage {
|
|
|
15
18
|
multiRemove?(keys: string[]): Promise<void>;
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
export type MMKVLocalCacheStorage = Pick<MMKV, 'getString' | 'set' | 'delete' | 'getAllKeys'>;
|
|
22
|
+
|
|
18
23
|
export type ErrorBoundaryProps = { error: Error; errorInfo: ErrorInfo; reset: () => void };
|
|
19
24
|
|
|
20
25
|
export type CommonComponent<P = {}> = ComponentType<P & { children?: ReactNode | undefined }>;
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const VERSION = '3.
|
|
1
|
+
const VERSION = '3.7.1';
|
|
2
2
|
export default VERSION;
|