refactor: remove dead code and add isAutoOpenEnabled helper
This commit is contained in:
@@ -233,15 +233,6 @@ def build_download_headers(
|
||||
return request_headers
|
||||
|
||||
|
||||
def _is_civitai_api_download_url(url: str) -> bool:
|
||||
parsed = urlparse(str(url or ""))
|
||||
host = parsed.hostname
|
||||
return (
|
||||
host_matches_domain(host, "civitai.com", "civitai.red")
|
||||
and parsed.path.startswith("/api/download/")
|
||||
)
|
||||
|
||||
|
||||
def _resolve_download_url_for_aria2(
|
||||
url: str,
|
||||
headers: Optional[Dict[str, str]] = None,
|
||||
|
||||
@@ -1059,6 +1059,13 @@ export class ModelResolver {
|
||||
// Run auto-resolve for 100% matches - returns the updated workflow
|
||||
const updatedWorkflow = await this.dialog.autoResolve100Percent();
|
||||
|
||||
return updatedWorkflow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if auto-open preference is enabled
|
||||
*/
|
||||
isAutoOpenEnabled() {
|
||||
return localStorage.getItem('ModelResolver.autoOpenOnMissing') !== 'false';
|
||||
}
|
||||
|
||||
|
||||
@@ -1187,27 +1187,6 @@ export const downloadTargetMethods = {
|
||||
return definition ? (localStorage.getItem(definition.storageKey) || '') : '';
|
||||
},
|
||||
|
||||
formatBaseModelMappingsForInput(mappings = {}) {
|
||||
return Object.entries(mappings || {})
|
||||
.map(([key, value]) => `${key}=${value}`)
|
||||
.join('\n');
|
||||
},
|
||||
|
||||
parseBaseModelMappingsInput(value = '') {
|
||||
const mappings = {};
|
||||
String(value || '').split(/\r?\n/).forEach(line => {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed || trimmed.startsWith('#')) return;
|
||||
const separator = trimmed.includes('=>') ? '=>' : '=';
|
||||
const index = trimmed.indexOf(separator);
|
||||
if (index <= 0) return;
|
||||
const key = trimmed.slice(0, index).trim();
|
||||
const mapped = trimmed.slice(index + separator.length).trim();
|
||||
if (key && mapped) mappings[key] = mapped;
|
||||
});
|
||||
return mappings;
|
||||
},
|
||||
|
||||
sanitizeDownloadPathSegment(value = '', fallback = '') {
|
||||
let text = String(value || '').trim() || fallback;
|
||||
text = text
|
||||
@@ -2165,10 +2144,6 @@ export const downloadTargetMethods = {
|
||||
window.addEventListener('blur', clearPointerActive, true);
|
||||
},
|
||||
|
||||
isDropdownListPointerActive(listEl) {
|
||||
return listEl?.dataset?.mlPointerActive === 'true';
|
||||
},
|
||||
|
||||
isPointerEventInsideElementBounds(event, element, tolerance = 0) {
|
||||
if (!event || !element || typeof event.clientX !== 'number' || typeof event.clientY !== 'number') {
|
||||
return false;
|
||||
|
||||
@@ -317,17 +317,10 @@ export const workflowStateMethods = {
|
||||
}
|
||||
},
|
||||
|
||||
rememberActiveWorkflow(workflow = null) {
|
||||
const currentWorkflow = workflow || this.getCurrentWorkflow();
|
||||
this.activeWorkflowRouteKey = this.getActiveWorkflowRouteKey();
|
||||
this.activeWorkflowSignature = this.getWorkflowSignature(currentWorkflow);
|
||||
},
|
||||
|
||||
getWorkflowScopedQueueKey(route = this.activeWorkflowRouteKey, signature = this.activeWorkflowSignature) {
|
||||
if (route && signature) return `${route}\n${signature}`;
|
||||
return route || signature || null;
|
||||
},
|
||||
|
||||
clonePendingResolutions(list = this.pendingResolutions) {
|
||||
try {
|
||||
return JSON.parse(JSON.stringify(Array.isArray(list) ? list : []));
|
||||
|
||||
@@ -22,21 +22,6 @@ export const renderFormatMethods = {
|
||||
return ` data-model="${this.escapeHtml(data)}" oncontextmenu="window.MLOpenContextMenu(event, this)"${tooltipAttr}`;
|
||||
},
|
||||
|
||||
getContextMenuProps(context = null, tooltip = '') {
|
||||
const data = this.encodeContextMenuModel(context);
|
||||
if (!data) return {};
|
||||
const props = {
|
||||
"data-model": data,
|
||||
oncontextmenu: (event) => {
|
||||
window.MLOpenContextMenu?.(event, event.currentTarget);
|
||||
}
|
||||
};
|
||||
if (tooltip) {
|
||||
props["data-tooltip"] = tooltip;
|
||||
}
|
||||
return props;
|
||||
},
|
||||
|
||||
setContextMenuElement(element, context = null, tooltip = '') {
|
||||
if (!element) return;
|
||||
const data = this.encodeContextMenuModel(context);
|
||||
|
||||
@@ -480,15 +480,6 @@ export const missingBrowserMethods = {
|
||||
};
|
||||
},
|
||||
|
||||
getVisibleMissingModels(missingModels = []) {
|
||||
const resolvedFilteredModels = this.showResolvedModels
|
||||
? missingModels
|
||||
: missingModels.filter(missing => !this.isMissingModelResolved(missing));
|
||||
|
||||
if (this.showAutoDownloadModels) return resolvedFilteredModels;
|
||||
return resolvedFilteredModels.filter(missing => !this.isAutoDownloadModel(missing));
|
||||
},
|
||||
|
||||
isAutoDownloadModel(missing = {}) {
|
||||
return Boolean(missing?.auto_download_capable || missing?.auto_download_candidate);
|
||||
},
|
||||
|
||||
@@ -1062,45 +1062,6 @@ export const modelInfoMethods = {
|
||||
window.open(sourceLink.url, '_blank', 'noopener,noreferrer');
|
||||
},
|
||||
|
||||
/**
|
||||
* Open model in CivitAI
|
||||
*/
|
||||
async openInCivitAI(model) {
|
||||
if (!model) return;
|
||||
|
||||
const directUrl = this.getKnownCivitaiModelUrl(model);
|
||||
if (directUrl) {
|
||||
window.open(directUrl, '_blank');
|
||||
return;
|
||||
}
|
||||
|
||||
const name = model.name || this.getFilenameFromPath(model.original_path) || '';
|
||||
if (!name) return;
|
||||
|
||||
try {
|
||||
// Search CivitAI for this model using hash (pass resolved_path for hash lookup)
|
||||
const data = await this.fetchJson('/model_resolver/civitai-search', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
filename: name,
|
||||
category: model.category,
|
||||
resolved_path: model.resolved_path || ''
|
||||
})
|
||||
}, 'Search CivitAI');
|
||||
|
||||
if (data && data.url) {
|
||||
window.open(data.url, '_blank');
|
||||
} else {
|
||||
throw new Error('No URL in search result');
|
||||
}
|
||||
} catch (e) {
|
||||
// Fall back to direct search
|
||||
const searchName = this.stripModelExtension(name);
|
||||
const searchUrl = `https://civitai.com/search?q=${encodeURIComponent(searchName)}`;
|
||||
window.open(searchUrl, '_blank');
|
||||
}
|
||||
},
|
||||
|
||||
getKnownCivitaiModelUrl(model = {}) {
|
||||
const candidates = [
|
||||
model.model_url,
|
||||
|
||||
Reference in New Issue
Block a user