fix(fontshareStore): add normalization to reduce amount of requests
This commit is contained in:
1 parent
746a377038
commit
1bd2a4f2f8
1 file changed
+9
-1
@@ -12,7 +12,15 @@ export class FontshareStore extends BaseFontStore<FontshareParams> {
|
||||
}
|
||||
|
||||
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<UnifiedFont[]> {
|
||||
|
||||
Reference in new issue
Block a user