Fix handlePreferences warning (#7556)
* Fix handlePreferences warning * Fix filtered array potentially being undefined
This commit is contained in:
parent
b562e67d02
commit
31eb0ca489
2 changed files with 6 additions and 4 deletions
|
|
@ -37,14 +37,16 @@ const UserHandler = <TBase extends Constructor<ServerDataOperatorBase>>(supercla
|
|||
*/
|
||||
handlePreferences = async ({preferences, prepareRecordsOnly = true, sync = false}: HandlePreferencesArgs): Promise<PreferenceModel[]> => {
|
||||
const records: PreferenceModel[] = [];
|
||||
const filtered = filterPreferences(preferences);
|
||||
if (!filtered?.length) {
|
||||
|
||||
if (!preferences?.length) {
|
||||
logWarning(
|
||||
'An empty or undefined "preferences" array has been passed to the handlePreferences method',
|
||||
);
|
||||
return records;
|
||||
}
|
||||
|
||||
const filtered = filterPreferences(preferences);
|
||||
|
||||
// WE NEED TO SYNC THE PREFS FROM WHAT WE GOT AND WHAT WE HAVE
|
||||
const deleteValues: PreferenceModel[] = [];
|
||||
const stored = await this.database.get(PREFERENCE).query().fetch() as PreferenceModel[];
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ export function getSidebarPreferenceAsBool(preferences: Preference[], name: stri
|
|||
return getPreferenceAsBool(preferences, Preferences.CATEGORIES.SIDEBAR_SETTINGS, name, defaultValue);
|
||||
}
|
||||
|
||||
export function filterPreferences(preferences?: PreferenceType[]) {
|
||||
if (!preferences?.length) {
|
||||
export function filterPreferences(preferences: PreferenceType[]) {
|
||||
if (!preferences.length) {
|
||||
return preferences;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue