From 1bd2a4f2f8be02e510a1ef8011cbf181edacf4a6 Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Tue, 20 Jan 2026 09:36:39 +0300 Subject: [PATCH] fix(fontshareStore): add normalization to reduce amount of requests --- src/entities/Font/model/store/fontshareStore.svelte.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/entities/Font/model/store/fontshareStore.svelte.ts b/src/entities/Font/model/store/fontshareStore.svelte.ts index cec798d..b2e438f 100644 --- a/src/entities/Font/model/store/fontshareStore.svelte.ts +++ b/src/entities/Font/model/store/fontshareStore.svelte.ts @@ -12,7 +12,15 @@ export class FontshareStore extends BaseFontStore { } protected getQueryKey(params: FontshareParams) { - return ['fontshare', params] as const; + // Normalize params to treat empty arrays/strings as undefined + const normalized = Object.entries(params).reduce((acc, [key, value]) => { + if (value === '' || (Array.isArray(value) && value.length === 0)) { + return acc; + } + return { ...acc, [key]: value }; + }, {}); + + return ['fontshare', normalized] as const; } protected async fetchFn(params: FontshareParams): Promise {