mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-06-21 09:52:03 -03:00
feat(models): add group-by-model option to collapse multiple versions into one card
Adds a 'Group by Model' toggle in Layout Settings. When enabled, only the latest version (highest civitai.id) of each Civitai model is shown as a single card — older versions sharing the same modelId are hidden. Backend dedup runs in BaseModelService.get_paginated_data() before filtering/pagination, ensuring correct paginated results. The setting is persisted via the existing settings pipeline and passed as a query parameter to the listing endpoint. Includes: - Backend: dedup logic, route param parsing, settings default - Frontend: API param, SettingsManager wiring, toggle UI - i18n: translations for all 10 locales - Tests: unit test covering dedup on/off and standalone items
This commit is contained in:
@@ -1271,6 +1271,11 @@ export class BaseModelApiClient {
|
||||
|
||||
params.append('recursive', pageState.searchOptions.recursive ? 'true' : 'false');
|
||||
|
||||
// Pass group-by-model mode to backend
|
||||
if (state.global.settings.group_by_model) {
|
||||
params.append('group_by_model', 'true');
|
||||
}
|
||||
|
||||
if (!isExcludedView && pageState.filters) {
|
||||
if (pageState.filters.tags && Object.keys(pageState.filters.tags).length > 0) {
|
||||
Object.entries(pageState.filters.tags).forEach(([tag, state]) => {
|
||||
|
||||
@@ -905,6 +905,12 @@ export class SettingsManager {
|
||||
showVersionOnCardCheckbox.checked = state.global.settings.show_version_on_card !== false;
|
||||
}
|
||||
|
||||
// Set group by model
|
||||
const groupByModelCheckbox = document.getElementById('groupByModel');
|
||||
if (groupByModelCheckbox) {
|
||||
groupByModelCheckbox.checked = !!state.global.settings.group_by_model;
|
||||
}
|
||||
|
||||
// Set model name display setting
|
||||
const modelNameDisplaySelect = document.getElementById('modelNameDisplay');
|
||||
if (modelNameDisplaySelect) {
|
||||
@@ -2011,7 +2017,7 @@ export class SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (settingKey === 'show_only_sfw' || settingKey === 'blur_mature_content') {
|
||||
if (settingKey === 'show_only_sfw' || settingKey === 'blur_mature_content' || settingKey === 'group_by_model') {
|
||||
this.reloadContent();
|
||||
}
|
||||
|
||||
@@ -3046,6 +3052,10 @@ export class SettingsManager {
|
||||
const useNewLicenseIcons = state.global.settings.use_new_license_icons !== false;
|
||||
document.body.classList.toggle('use-new-license-icons', useNewLicenseIcons);
|
||||
|
||||
// Apply group-by-model mode
|
||||
const groupByModel = !!state.global.settings.group_by_model;
|
||||
document.body.classList.toggle('group-by-model', groupByModel);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ const DEFAULT_SETTINGS_BASE = Object.freeze({
|
||||
backup_retention_count: 5,
|
||||
strip_lora_on_copy: false,
|
||||
use_new_license_icons: true,
|
||||
group_by_model: false,
|
||||
});
|
||||
|
||||
export function createDefaultSettings() {
|
||||
|
||||
Reference in New Issue
Block a user