chore: delete unused code
This commit is contained in:
@@ -1,115 +0,0 @@
|
||||
import {
|
||||
filterValidValues,
|
||||
isValidFontCategory,
|
||||
isValidFontProvider,
|
||||
isValidFontSubset,
|
||||
} from '$entities/Font/lib/typeGuards';
|
||||
import type { UnifiedFontStore } from '$entities/Font/model/store';
|
||||
import { filterManager } from '$features/FilterFonts';
|
||||
import type { Property } from '$shared/lib';
|
||||
|
||||
/**
|
||||
* ============================================================================
|
||||
* FILTER BRIDGE
|
||||
* ============================================================================
|
||||
*
|
||||
* Bridges the UI filter state (filterManager from FilterFonts feature) with the
|
||||
* unified font store (unifiedFontStore from Font entity).
|
||||
*
|
||||
* OPTIMIZATIONS (P1):
|
||||
* - Runtime type validation using type guards
|
||||
* - No more 'as any[]' casts - type-safe assignments
|
||||
*/
|
||||
|
||||
// ... (comments)
|
||||
|
||||
// ============================================================================
|
||||
// FILTER GROUP MAPPING
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Get selected values from a filter manager group by ID
|
||||
*/
|
||||
function getSelectedFilterValues(groupId: string): string[] {
|
||||
const group = filterManager.getGroup(groupId);
|
||||
if (!group) return [];
|
||||
|
||||
return group.instance.selectedProperties.map((property: Property<string>) => property.value);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// SYNC LOGIC
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Sync filter manager state to unified font store
|
||||
*
|
||||
* @param store - The unified font store instance
|
||||
*/
|
||||
export function syncFilters(store: UnifiedFontStore): void {
|
||||
const providers = getSelectedFilterValues('providers');
|
||||
const categories = getSelectedFilterValues('categories');
|
||||
const subsets = getSelectedFilterValues('subsets');
|
||||
|
||||
// Validate and filter providers
|
||||
const validProviders = filterValidValues(providers, isValidFontProvider);
|
||||
|
||||
// Validate and filter categories
|
||||
const validCategories = filterValidValues(categories, isValidFontCategory);
|
||||
|
||||
// Validate and filter subsets
|
||||
const validSubsets = filterValidValues(subsets, isValidFontSubset);
|
||||
|
||||
// Update unified store filters with validated, type-safe values
|
||||
store.filters = {
|
||||
providers: validProviders,
|
||||
categories: validCategories,
|
||||
subsets: validSubsets,
|
||||
searchQuery: store.filters.searchQuery,
|
||||
};
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// PUBLIC API
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Apply current filters and fetch fonts from providers
|
||||
*
|
||||
* @param store - The unified font store instance
|
||||
*/
|
||||
export async function applyFilters(store: UnifiedFontStore): Promise<void> {
|
||||
await store.fetchFonts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all filters to their default state
|
||||
*
|
||||
* @param store - The unified font store instance
|
||||
*/
|
||||
export function resetFilters(store: UnifiedFontStore): void {
|
||||
// Reset filter manager selections
|
||||
filterManager.deselectAllGlobal();
|
||||
|
||||
// Clear unified store filters
|
||||
store.clearFilters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply current filter selections and fetch fonts
|
||||
*
|
||||
* @param store - The unified font store instance
|
||||
*/
|
||||
export async function applyFilterType(store: UnifiedFontStore): Promise<void> {
|
||||
syncFilters(store);
|
||||
await store.fetchFonts();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// RE-EXPORTS FOR CONVENIENCE
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Re-export filter manager for direct access
|
||||
*/
|
||||
export { filterManager } from '$features/FilterFonts';
|
||||
Reference in New Issue
Block a user