Add refresh metadata functionality to context menu and improve item state handling

This commit is contained in:
Will Miao
2025-02-18 20:08:36 +08:00
parent 612136d848
commit 80b860e98a
5 changed files with 63 additions and 5 deletions

View File

@@ -286,4 +286,33 @@ export async function refreshLoras() {
state.loadingManager.hide();
state.loadingManager.restoreProgressBar();
}
}
export async function refreshSingleLoraMetadata(filePath) {
try {
const response = await fetch('/api/fetch-civitai', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ file_path: filePath })
});
if (!response.ok) {
throw new Error('Failed to refresh metadata');
}
const data = await response.json();
if (data.success) {
showToast('Metadata refreshed successfully', 'success');
// Reload the current view to show updated data
await resetAndReload();
} else {
throw new Error(data.error || 'Failed to refresh metadata');
}
} catch (error) {
console.error('Error refreshing metadata:', error);
showToast(error.message, 'error');
}
}