mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
refactor(filter): extract preset management logic into FilterPresetManager
Move filter preset creation, deletion, application, and storage logic from FilterManager into a dedicated FilterPresetManager class to improve separation of concerns and maintainability. - Add FilterPresetManager with preset CRUD operations - Update FilterManager to use preset manager via composition - Handle EMPTY_WILDCARD_MARKER for wildcard base model filters - Add preset-related translations to all locale files - Update filter preset UI styling and interactions
This commit is contained in:
@@ -59,6 +59,18 @@ export class BaseModelApiClient {
|
||||
sort_by: pageState.sortBy
|
||||
}, pageState);
|
||||
|
||||
// If params is null, it means wildcard resolved to no matches - return empty results
|
||||
if (params === null) {
|
||||
return {
|
||||
items: [],
|
||||
totalItems: 0,
|
||||
totalPages: 0,
|
||||
currentPage: page,
|
||||
hasMore: false,
|
||||
folders: []
|
||||
};
|
||||
}
|
||||
|
||||
const response = await fetch(`${this.apiConfig.endpoints.list}?${params}`);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch ${this.apiConfig.config.displayName}s: ${response.statusText}`);
|
||||
@@ -868,6 +880,13 @@ export class BaseModelApiClient {
|
||||
}
|
||||
|
||||
if (pageState.filters.baseModel && pageState.filters.baseModel.length > 0) {
|
||||
// Check for empty wildcard marker - if present, no models should match
|
||||
const EMPTY_WILDCARD_MARKER = '__EMPTY_WILDCARD_RESULT__';
|
||||
if (pageState.filters.baseModel.length === 1 &&
|
||||
pageState.filters.baseModel[0] === EMPTY_WILDCARD_MARKER) {
|
||||
// Wildcard resolved to no matches - return empty results
|
||||
return null; // Signal to return empty results
|
||||
}
|
||||
pageState.filters.baseModel.forEach(model => {
|
||||
params.append('base_model', model);
|
||||
});
|
||||
|
||||
@@ -103,6 +103,19 @@ export async function fetchRecipesPage(page = 1, pageSize = 100) {
|
||||
|
||||
// Add base model filters
|
||||
if (pageState.filters?.baseModel && pageState.filters.baseModel.length) {
|
||||
// Check for empty wildcard marker - if present, no models should match
|
||||
const EMPTY_WILDCARD_MARKER = '__EMPTY_WILDCARD_RESULT__';
|
||||
if (pageState.filters.baseModel.length === 1 &&
|
||||
pageState.filters.baseModel[0] === EMPTY_WILDCARD_MARKER) {
|
||||
// Wildcard resolved to no matches - return empty results
|
||||
return {
|
||||
items: [],
|
||||
totalItems: 0,
|
||||
totalPages: 0,
|
||||
currentPage: page,
|
||||
hasMore: false
|
||||
};
|
||||
}
|
||||
params.append('base_models', pageState.filters.baseModel.join(','));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user