From 706581b28a29c2a09982051c53f29c862c045252 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:12:47 -0500 Subject: [PATCH] fix: slight optimization for query requests --- src/components/QueryData.jsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/QueryData.jsx b/src/components/QueryData.jsx index 5599fe078..a07014627 100644 --- a/src/components/QueryData.jsx +++ b/src/components/QueryData.jsx @@ -31,6 +31,14 @@ const userSettingsCategory = (category) => { } } +/** + * @template {keyof import('@rm/types').AllFilters} T + * @param {import('@rm/types').AllFilters[T]} requestedFilters + * @param {Record} userSettings + * @param {T} category + * @param {string[]} [onlyAreas] + * @returns + */ const trimFilters = (requestedFilters, userSettings, category, onlyAreas) => { const { filters: staticFilters } = useStatic.getState() const easyMode = !!requestedFilters?.easyMode @@ -53,11 +61,14 @@ const trimFilters = (requestedFilters, userSettings, category, onlyAreas) => { entryV } }) - Object.entries(requestedFilters.filter).forEach((filter) => { - const [id, specifics] = filter + Object.entries(requestedFilters.filter).forEach(([id, specifics]) => { + // eslint-disable-next-line no-unused-vars + const { enabled, size, ...rest } = (easyMode + ? requestedFilters.ivOr + : specifics) || { all: false, adv: '' } if (specifics && specifics.enabled && staticFilters[category]?.filter[id]) { - trimmed[id] = easyMode ? requestedFilters.ivOr : specifics + trimmed[id] = rest } }) return trimmed