Skip to content

Commit

Permalink
fix: add safeguard for querying app settings (#2765)
Browse files Browse the repository at this point in the history
* fix: add safeguard for querying app settings

* fix: test
  • Loading branch information
isekovanic authored Nov 28, 2024
1 parent 837c2d2 commit f26e974
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('useAppSettings', () => {
auto_translation_enabled: true,
}),
),
userID: 'some-user-id',
} as unknown as StreamChat,
isOnline,
false,
Expand Down
2 changes: 2 additions & 0 deletions package/src/components/Chat/hooks/useAppSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const useAppSettings = <
* Fetches app settings from the backend when offline support is disabled.
*/
const enforceAppSettingsWithoutOfflineSupport = async () => {
if (!client.userID) return;

try {
const appSettings = await client.getAppSettings();
if (isMounted.current) {
Expand Down

0 comments on commit f26e974

Please sign in to comment.