diff --git a/app/database/operator/server_data_operator/handlers/user.ts b/app/database/operator/server_data_operator/handlers/user.ts index b5c2813b2..2399980ed 100644 --- a/app/database/operator/server_data_operator/handlers/user.ts +++ b/app/database/operator/server_data_operator/handlers/user.ts @@ -37,14 +37,16 @@ const UserHandler = >(supercla */ handlePreferences = async ({preferences, prepareRecordsOnly = true, sync = false}: HandlePreferencesArgs): Promise => { 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[]; diff --git a/app/helpers/api/preference.ts b/app/helpers/api/preference.ts index b3f824b53..67dc26220 100644 --- a/app/helpers/api/preference.ts +++ b/app/helpers/api/preference.ts @@ -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; }