feat: enhance LoRA metadata handling by adding model IDs and updating recipe data structure. Fixes #246

This commit is contained in:
Will Miao
2025-06-24 11:12:21 +08:00
parent f6ef428008
commit d0ed1213d8
9 changed files with 38 additions and 58 deletions

View File

@@ -2,6 +2,7 @@
import { showToast, copyToClipboard, sendLoraToWorkflow } from '../utils/uiHelpers.js';
import { modalManager } from '../managers/ModalManager.js';
import { getCurrentPageState } from '../state/index.js';
import { state } from '../state/index.js';
class RecipeCard {
constructor(recipe, clickHandler) {
@@ -141,6 +142,7 @@ class RecipeCard {
try {
// Get recipe ID
const recipeId = this.recipe.id;
const filePath = this.recipe.file_path;
if (!recipeId) {
showToast('Cannot delete recipe: Missing recipe ID', 'error');
return;
@@ -184,6 +186,7 @@ class RecipeCard {
// Store recipe ID in the modal for the delete confirmation handler
deleteModal.dataset.recipeId = recipeId;
deleteModal.dataset.filePath = filePath;
// Update button event handlers
cancelBtn.onclick = () => modalManager.closeModal('deleteModal');
@@ -227,7 +230,7 @@ class RecipeCard {
.then(data => {
showToast('Recipe deleted successfully', 'success');
window.recipeManager.loadRecipes();
state.virtualScroller.removeItemByFilePath(deleteModal.dataset.filePath);
modalManager.closeModal('deleteModal');
})

View File

@@ -950,13 +950,6 @@ class RecipeModal {
// Remove .safetensors extension if present
fileName = fileName.replace(/\.safetensors$/, '');
// Get the deleted lora data
const deletedLora = this.currentRecipe.loras[loraIndex];
if (!deletedLora) {
showToast('Error: Could not find the LoRA in the recipe', 'error');
return;
}
state.loadingManager.showSimpleLoading('Reconnecting LoRA...');
// Call API to reconnect the LoRA
@@ -967,7 +960,7 @@ class RecipeModal {
},
body: JSON.stringify({
recipe_id: this.recipeId,
lora_data: deletedLora,
lora_index: loraIndex,
target_name: fileName
})
});