Skip to content

Commit f26e974

Browse files
authored
fix: add safeguard for querying app settings (#2765)
* fix: add safeguard for querying app settings * fix: test
1 parent 837c2d2 commit f26e974

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

package/src/components/Chat/hooks/__tests__/useAppSettings.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ describe('useAppSettings', () => {
1818
auto_translation_enabled: true,
1919
}),
2020
),
21+
userID: 'some-user-id',
2122
} as unknown as StreamChat,
2223
isOnline,
2324
false,

package/src/components/Chat/hooks/useAppSettings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export const useAppSettings = <
2222
* Fetches app settings from the backend when offline support is disabled.
2323
*/
2424
const enforceAppSettingsWithoutOfflineSupport = async () => {
25+
if (!client.userID) return;
26+
2527
try {
2628
const appSettings = await client.getAppSettings();
2729
if (isMounted.current) {

0 commit comments

Comments
 (0)