refactor(GetFonts): consolidate filtersStore wiring into bindings

Move the filtersStore → filterManager.setGroups $effect.root out of
manager.svelte.ts into bindings.svelte.ts so all cross-store reactive
wiring for the feature lives in one place. manager.svelte.ts now only
constructs and exports the singleton.
This commit is contained in:
Ilia Mashkov
2026-05-24 15:08:54 +03:00
parent e60309af78
commit 33d3429060
2 changed files with 29 additions and 29 deletions
@@ -13,9 +13,34 @@ import { fontStore } from '$entities/Font';
import { untrack } from 'svelte';
import { mapManagerToParams } from '../../lib/mapper/mapManagerToParams';
import { sortStore } from '../store/sortStore.svelte';
import { filtersStore } from './filters.svelte';
import { filterManager } from './manager.svelte';
$effect.root(() => {
/**
* Populate filterManager groups when backend filter metadata resolves.
* filtersStore is async; until it loads, filterManager has empty groups
* and the UI renders nothing for them.
*/
$effect(() => {
const dynamicFilters = filtersStore.filters;
if (dynamicFilters.length > 0) {
filterManager.setGroups(
dynamicFilters.map(filter => ({
id: filter.id,
label: filter.name,
properties: filter.options.sort((a, b) => b.count - a.count).map(opt => ({
id: opt.id,
name: opt.name,
value: opt.value,
selected: false,
})),
})),
);
}
});
/**
* Mirror filter selections + debounced search query into fontStore params.
* untrack the write so fontStore's internal $state reads don't feed back