@@ -72,26 +72,8 @@ export const SendbirdUIKit = Object.freeze({
72
72
} ,
73
73
} ) ;
74
74
75
- export type ChatOmittedInitParams = Omit <
76
- SendbirdChatParams < [ GroupChannelModule , OpenChannelModule ] > ,
77
- ( typeof chatOmitKeys ) [ number ]
78
- > ;
79
-
80
- const chatOmitKeys = [
81
- 'appId' ,
82
- 'newInstance' ,
83
- 'modules' ,
84
- 'debugMode' ,
85
- 'appVersion' ,
86
- 'localCacheEnabled' ,
87
- 'useAsyncStorageStore' ,
88
- 'useMMKVStorageStore' ,
89
- ] as const ;
90
- function sanitizeChatOptions < T extends Record < string , unknown > > ( chatOptions : T ) : T {
91
- const opts = { ...chatOptions } ;
92
- chatOmitKeys . forEach ( ( key ) => delete opts [ key ] ) ;
93
- return opts ;
94
- }
75
+ export type ChatOmittedInitParams = SendbirdChatParams < [ GroupChannelModule , OpenChannelModule ] > ;
76
+
95
77
export type SendbirdUIKitContainerProps = React . PropsWithChildren < {
96
78
appId : string ;
97
79
platformServices : {
@@ -184,7 +166,7 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
184
166
185
167
const [ internalStorage ] = useState ( ( ) => new InternalLocalCacheStorage ( chatOptions . localCacheStorage ) ) ;
186
168
const [ sdkInstance , setSdkInstance ] = useState < SendbirdChatSDK > ( ( ) => {
187
- const sendbird = initializeSendbird ( appId , sanitizeChatOptions ( chatOptions ) ) ;
169
+ const sendbird = initializeSendbird ( appId , chatOptions ) ;
188
170
unsubscribes . current = sendbird . unsubscribes ;
189
171
return sendbird . chatSDK ;
190
172
} ) ;
@@ -196,7 +178,7 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
196
178
197
179
useLayoutEffect ( ( ) => {
198
180
if ( ! isFirstMount ) {
199
- const sendbird = initializeSendbird ( appId , sanitizeChatOptions ( chatOptions ) ) ;
181
+ const sendbird = initializeSendbird ( appId , chatOptions ) ;
200
182
setSdkInstance ( sendbird . chatSDK ) ;
201
183
unsubscribes . current = sendbird . unsubscribes ;
202
184
}
@@ -307,24 +289,24 @@ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
307
289
) ;
308
290
} ;
309
291
310
- interface InitOptions extends ChatOmittedInitParams {
292
+ type InitOptions = Partial < ChatOmittedInitParams > & {
311
293
localCacheStorage : LocalCacheStorage ;
312
294
onInitialized ?: ( sdk : SendbirdChatSDK ) => SendbirdChatSDK ;
313
- }
295
+ } ;
314
296
const initializeSendbird = ( appId : string , options : InitOptions ) => {
315
297
let chatSDK : SendbirdChatSDK ;
316
298
const unsubscribes : Array < ( ) => void > = [ ] ;
317
299
const { localCacheStorage, onInitialized, ...chatInitParams } = options ;
318
300
319
301
const isMMKVStorage = 'getString' in localCacheStorage ;
320
302
chatSDK = SendbirdChat . init ( {
321
- ...chatInitParams ,
322
303
appId,
323
304
newInstance : true ,
324
305
modules : [ new GroupChannelModule ( ) , new OpenChannelModule ( ) ] ,
325
306
localCacheEnabled : true ,
326
307
useMMKVStorageStore : isMMKVStorage ? ( localCacheStorage as MMKV ) : undefined ,
327
308
useAsyncStorageStore : ! isMMKVStorage ? ( localCacheStorage as AsyncStorageStatic ) : undefined ,
309
+ ...chatInitParams ,
328
310
} ) ;
329
311
330
312
if ( onInitialized ) {
0 commit comments