refactor: optimize function for empty array

This commit is contained in:
sundasnoreen12
2024-05-16 12:53:36 +05:00
parent e623f03c4b
commit 82c9e07f0f

View File

@@ -5,5 +5,11 @@ export const notificationChannels = () => ({ WEB: 'web', ...(getConfig().SHOW_EM
export const shouldHideAppPreferences = (preferences, appId) => {
const appPreferences = preferences.filter(pref => pref.appId === appId);
return appPreferences.length === 1 && appPreferences[0].id === 'core' && !appPreferences[0].coreNotificationTypes.length;
if (appPreferences.length !== 1) {
return false;
}
const firstPreference = appPreferences[0];
return firstPreference?.id === 'core' && (!firstPreference.coreNotificationTypes?.length);
};