Enhance model deletion handling in UI: integrate virtual scroller updates and remove legacy UI card removal logic.

This commit is contained in:
Will Miao
2025-05-13 17:50:28 +08:00
parent 3e06938b05
commit 84bfad7ce5
4 changed files with 76 additions and 15 deletions

View File

@@ -455,10 +455,15 @@ export async function deleteModel(filePath, modelType = 'lora') {
const data = await response.json();
if (data.success) {
// Remove the card from UI
const card = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
if (card) {
card.remove();
// If virtual scroller exists, update its data
if (state.virtualScroller) {
state.virtualScroller.removeItemByFilePath(filePath);
} else {
// Legacy approach: remove the card from UI directly
const card = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
if (card) {
card.remove();
}
}
showToast(`${modelType} deleted successfully`, 'success');
@@ -673,10 +678,15 @@ export async function excludeModel(filePath, modelType = 'lora') {
const data = await response.json();
if (data.success) {
// Remove the card from UI
const card = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
if (card) {
card.remove();
// If virtual scroller exists, update its data
if (state.virtualScroller) {
state.virtualScroller.removeItemByFilePath(filePath);
} else {
// Legacy approach: remove the card from UI directly
const card = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
if (card) {
card.remove();
}
}
showToast(`${modelType} excluded successfully`, 'success');

View File

@@ -13,7 +13,6 @@ import {
excludeModel as baseExcludeModel
} from './baseModelApi.js';
import { state, getCurrentPageState } from '../state/index.js';
import { showToast } from '../utils/uiHelpers.js';
/**
* Save model metadata to the server