Skip to content

Commit 8803aee

Browse files
committed
allow localCacheEnabled override through sdkInitParams
1 parent 086f90a commit 8803aee

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/lib/hooks/useConnect/__test__/setupConnection.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,27 @@ describe('useConnect/setupConnection/initSDK', () => {
265265
});
266266
expect(newSdk).toEqual(mockSdk);
267267
});
268+
it('should override default localCacheEnabled when provided in sdkInitParams', async () => {
269+
const setUpConnectionProps = generateSetUpConnectionParams();
270+
const { appId } = setUpConnectionProps;
271+
const sdkInitParams = {
272+
localCacheEnabled: false,
273+
};
274+
275+
const newSdk = initSDK({ appId, sdkInitParams });
276+
277+
// @ts-ignore
278+
expect(require('@sendbird/chat').init).toBeCalledWith({
279+
appId,
280+
newInstance: false,
281+
modules: [
282+
// @ts-ignore
283+
new (require('@sendbird/chat/groupChannel').GroupChannelModule)(),
284+
// @ts-ignore
285+
new (require('@sendbird/chat/openChannel').OpenChannelModule)(),
286+
],
287+
localCacheEnabled: false,
288+
});
289+
expect(newSdk).toEqual(mockSdk);
290+
});
268291
});

src/lib/hooks/useConnect/setupConnection.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,13 @@ export function initSDK({
173173
sdkInitParams?: SendbirdChatInitParams;
174174
customExtensionParams?: CustomExtensionParams;
175175
}) {
176-
const params = Object.assign(sdkInitParams, {
176+
const params = {
177177
appId,
178178
modules: [new GroupChannelModule(), new OpenChannelModule()],
179179
newInstance: isNewApp,
180180
localCacheEnabled: true,
181-
});
181+
...sdkInitParams,
182+
};
182183

183184
if (customApiHost) params.customApiHost = customApiHost;
184185
if (customWebSocketHost) params.customWebSocketHost = customWebSocketHost;

0 commit comments

Comments
 (0)