diff --git a/static/js/api/checkpointApi.js b/static/js/api/checkpointApi.js index 844f3228..0a8c889b 100644 --- a/static/js/api/checkpointApi.js +++ b/static/js/api/checkpointApi.js @@ -109,6 +109,9 @@ export async function saveModelMetadata(filePath, data) { if (!response.ok) { throw new Error('Failed to save metadata'); } + + // Update the virtual scroller with the new metadata + state.virtualScroller.updateSingleItem(filePath, data); return response.json(); } finally { diff --git a/static/js/api/loraApi.js b/static/js/api/loraApi.js index d727d183..8781635f 100644 --- a/static/js/api/loraApi.js +++ b/static/js/api/loraApi.js @@ -36,6 +36,9 @@ export async function saveModelMetadata(filePath, data) { if (!response.ok) { throw new Error('Failed to save metadata'); } + + // Update the virtual scroller with the new data + state.virtualScroller.updateSingleItem(filePath, data); return response.json(); } finally { diff --git a/static/js/components/CheckpointCard.js b/static/js/components/CheckpointCard.js index f494d6f9..faa5dedf 100644 --- a/static/js/components/CheckpointCard.js +++ b/static/js/components/CheckpointCard.js @@ -219,18 +219,9 @@ export function createCheckpointCard(checkpoint) { favorite: newFavoriteState }); - // Update the UI if (newFavoriteState) { - starIcon.classList.remove('far'); - starIcon.classList.add('fas', 'favorite-active'); - starIcon.title = 'Remove from favorites'; - card.dataset.favorite = 'true'; showToast('Added to favorites', 'success'); } else { - starIcon.classList.remove('fas', 'favorite-active'); - starIcon.classList.add('far'); - starIcon.title = 'Add to favorites'; - card.dataset.favorite = 'false'; showToast('Removed from favorites', 'success'); } } catch (error) { diff --git a/static/js/components/ContextMenu/CheckpointContextMenu.js b/static/js/components/ContextMenu/CheckpointContextMenu.js index c5b46eec..16ab4b44 100644 --- a/static/js/components/ContextMenu/CheckpointContextMenu.js +++ b/static/js/components/ContextMenu/CheckpointContextMenu.js @@ -3,7 +3,6 @@ import { ModelContextMenuMixin } from './ModelContextMenuMixin.js'; import { refreshSingleCheckpointMetadata, saveModelMetadata, replaceCheckpointPreview, resetAndReload } from '../../api/checkpointApi.js'; import { showToast } from '../../utils/uiHelpers.js'; import { showExcludeModal } from '../../utils/modalUtils.js'; -import { state } from '../../state/index.js'; export class CheckpointContextMenu extends BaseContextMenu { constructor() { diff --git a/static/js/components/ContextMenu/LoraContextMenu.js b/static/js/components/ContextMenu/LoraContextMenu.js index fbd9e9ea..72ac7519 100644 --- a/static/js/components/ContextMenu/LoraContextMenu.js +++ b/static/js/components/ContextMenu/LoraContextMenu.js @@ -1,7 +1,7 @@ import { BaseContextMenu } from './BaseContextMenu.js'; import { ModelContextMenuMixin } from './ModelContextMenuMixin.js'; import { refreshSingleLoraMetadata, saveModelMetadata, replacePreview, resetAndReload } from '../../api/loraApi.js'; -import { showToast, copyToClipboard, sendLoraToWorkflow } from '../../utils/uiHelpers.js'; +import { copyToClipboard, sendLoraToWorkflow } from '../../utils/uiHelpers.js'; import { showExcludeModal, showDeleteModal } from '../../utils/modalUtils.js'; export class LoraContextMenu extends BaseContextMenu { diff --git a/static/js/components/ContextMenu/ModelContextMenuMixin.js b/static/js/components/ContextMenu/ModelContextMenuMixin.js index a5a0c69b..7314651d 100644 --- a/static/js/components/ContextMenu/ModelContextMenuMixin.js +++ b/static/js/components/ContextMenu/ModelContextMenuMixin.js @@ -26,24 +26,6 @@ export const ModelContextMenuMixin = { try { await this.saveModelMetadata(filePath, { preview_nsfw_level: level }); - // Update card data - const card = document.querySelector(`.lora-card[data-filepath="${filePath}"]`); - if (card) { - let metaData = {}; - try { - metaData = JSON.parse(card.dataset.meta || '{}'); - } catch (err) { - console.error('Error parsing metadata:', err); - } - - metaData.preview_nsfw_level = level; - card.dataset.meta = JSON.stringify(metaData); - card.dataset.nsfwLevel = level.toString(); - - // Apply blur effect immediately - this.updateCardBlurEffect(card, level); - } - showToast(`Content rating set to ${getNSFWLevelName(level)}`, 'success'); this.nsfwSelector.style.display = 'none'; } catch (error) { diff --git a/static/js/components/LoraCard.js b/static/js/components/LoraCard.js index 292eb5bd..0fcefc18 100644 --- a/static/js/components/LoraCard.js +++ b/static/js/components/LoraCard.js @@ -162,18 +162,9 @@ async function toggleFavorite(card) { favorite: newFavoriteState }); - // Update the UI if (newFavoriteState) { - starIcon.classList.remove('far'); - starIcon.classList.add('fas', 'favorite-active'); - starIcon.title = 'Remove from favorites'; - card.dataset.favorite = 'true'; showToast('Added to favorites', 'success'); } else { - starIcon.classList.remove('fas', 'favorite-active'); - starIcon.classList.add('far'); - starIcon.title = 'Add to favorites'; - card.dataset.favorite = 'false'; showToast('Removed from favorites', 'success'); } } catch (error) { diff --git a/static/js/components/checkpointModal/ModelMetadata.js b/static/js/components/checkpointModal/ModelMetadata.js index 6bda56d7..37b0d831 100644 --- a/static/js/components/checkpointModal/ModelMetadata.js +++ b/static/js/components/checkpointModal/ModelMetadata.js @@ -114,16 +114,6 @@ export function setupModelNameEditing(filePath) { await saveModelMetadata(filePath, { model_name: newModelName }); - // Update the corresponding checkpoint card's dataset and display - updateModelCard(filePath, { model_name: newModelName }); - - // BUGFIX: Directly update the card's dataset.name attribute to ensure - // it's correctly read when reopening the modal - const checkpointCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`); - if (checkpointCard) { - checkpointCard.dataset.name = newModelName; - } - showToast('Model name updated successfully', 'success'); } catch (error) { console.error('Error updating model name:', error); @@ -300,9 +290,6 @@ async function saveBaseModel(filePath, originalValue) { try { await saveModelMetadata(filePath, { base_model: newBaseModel }); - // Update the card with the new base model - updateModelCard(filePath, { base_model: newBaseModel }); - showToast('Base model updated successfully', 'success'); } catch (error) { showToast('Failed to update base model', 'error'); diff --git a/static/js/components/checkpointModal/ModelTags.js b/static/js/components/checkpointModal/ModelTags.js index b5940f3c..d3256608 100644 --- a/static/js/components/checkpointModal/ModelTags.js +++ b/static/js/components/checkpointModal/ModelTags.js @@ -463,12 +463,6 @@ async function saveTags() { // Exit edit mode editBtn.click(); - // Update the checkpoint card's dataset - const checkpointCard = document.querySelector(`.checkpoint-card[data-filepath="${filePath}"]`); - if (checkpointCard) { - checkpointCard.dataset.tags = JSON.stringify(tags); - } - showToast('Tags updated successfully', 'success'); } catch (error) { console.error('Error saving tags:', error); diff --git a/static/js/components/checkpointModal/index.js b/static/js/components/checkpointModal/index.js index 64c21f47..9bfbaf22 100644 --- a/static/js/components/checkpointModal/index.js +++ b/static/js/components/checkpointModal/index.js @@ -258,9 +258,6 @@ async function saveNotes(filePath) { try { await saveModelMetadata(filePath, { notes: content }); - // Update the corresponding checkpoint card's dataset - updateModelCard(filePath, { notes: content }); - showToast('Notes saved successfully', 'success'); } catch (error) { showToast('Failed to save notes', 'error'); diff --git a/static/js/components/loraModal/ModelMetadata.js b/static/js/components/loraModal/ModelMetadata.js index 5ae63d31..11833dec 100644 --- a/static/js/components/loraModal/ModelMetadata.js +++ b/static/js/components/loraModal/ModelMetadata.js @@ -115,16 +115,6 @@ export function setupModelNameEditing(filePath) { await saveModelMetadata(filePath, { model_name: newModelName }); - // Update the corresponding lora card's dataset and display - updateModelCard(filePath, { model_name: newModelName }); - - // BUGFIX: Directly update the card's dataset.name attribute to ensure - // it's correctly read when reopening the modal - const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`); - if (loraCard) { - loraCard.dataset.name = newModelName; - } - showToast('Model name updated successfully', 'success'); } catch (error) { console.error('Error updating model name:', error); @@ -304,9 +294,6 @@ async function saveBaseModel(filePath, originalValue) { try { await saveModelMetadata(filePath, { base_model: newBaseModel }); - // Update the corresponding lora card's dataset - updateModelCard(filePath, { base_model: newBaseModel }); - showToast('Base model updated successfully', 'success'); } catch (error) { showToast('Failed to update base model', 'error'); diff --git a/static/js/components/loraModal/ModelTags.js b/static/js/components/loraModal/ModelTags.js index 5d31006b..97ef62b7 100644 --- a/static/js/components/loraModal/ModelTags.js +++ b/static/js/components/loraModal/ModelTags.js @@ -463,15 +463,6 @@ async function saveTags() { // Exit edit mode editBtn.click(); - // Update the LoRA card's dataset - const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`); - if (loraCard) { - loraCard.dataset.tags = JSON.stringify(tags); - - // Also update the card in the DOM - // updateLoraCard(loraCard, { tags: tags }); - } - showToast('Tags updated successfully', 'success'); } catch (error) { console.error('Error saving tags:', error); diff --git a/static/js/components/loraModal/PresetTags.js b/static/js/components/loraModal/PresetTags.js index 4e331159..dc08dd20 100644 --- a/static/js/components/loraModal/PresetTags.js +++ b/static/js/components/loraModal/PresetTags.js @@ -62,6 +62,5 @@ window.removePreset = async function(key) { usage_tips: newPresetsJson }); - loraCard.dataset.usage_tips = newPresetsJson; document.querySelector('.preset-tags').innerHTML = renderPresetTags(currentPresets); }; \ No newline at end of file diff --git a/static/js/components/loraModal/TriggerWords.js b/static/js/components/loraModal/TriggerWords.js index 2589dd82..39d311a7 100644 --- a/static/js/components/loraModal/TriggerWords.js +++ b/static/js/components/loraModal/TriggerWords.js @@ -620,28 +620,6 @@ async function saveTriggerWords() { // Exit edit mode without restoring original trigger words editBtn.click(); - // Update the LoRA card's dataset - const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`); - if (loraCard) { - try { - // Create a proper structure for civitai data - let civitaiData = {}; - - // Parse existing data if available - if (loraCard.dataset.meta) { - civitaiData = JSON.parse(loraCard.dataset.meta); - } - - // Update trainedWords property - civitaiData.trainedWords = words; - - // Update the meta dataset attribute with the full civitai data - loraCard.dataset.meta = JSON.stringify(civitaiData); - } catch (e) { - console.error('Error updating civitai data:', e); - } - } - // If we saved an empty array and there's a no-trigger-words element, show it const noTriggerWords = triggerWordsSection.querySelector('.no-trigger-words'); const tagsContainer = triggerWordsSection.querySelector('.trigger-words-tags'); diff --git a/static/js/components/loraModal/index.js b/static/js/components/loraModal/index.js index 13fa3406..29c4c923 100644 --- a/static/js/components/loraModal/index.js +++ b/static/js/components/loraModal/index.js @@ -272,9 +272,6 @@ window.saveNotes = async function(filePath) { try { await saveModelMetadata(filePath, { notes: content }); - // Update the corresponding lora card's dataset - updateModelCard(filePath, { notes: content }); - showToast('Notes saved successfully', 'success'); } catch (error) { showToast('Failed to save notes', 'error'); @@ -339,9 +336,6 @@ function setupEditableFields(filePath) { usage_tips: newPresetsJson }); - // Update the card with the new usage tips - updateModelCard(filePath, { usage_tips: newPresetsJson }); - presetTags.innerHTML = renderPresetTags(currentPresets); presetSelector.value = '';