fix: add missing cancelAbstractPreview function and related state

The openImportWindow and closeImportWindow functions referenced
cancelAbstractPreview which was not defined. Added:
- hoverTimerId, hoveredItemKey, previewItemKey to state
- previewPopover to elements object
- cancelAbstractPreview function

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Saberlve 2026-04-15 16:33:41 +08:00
parent d624315fbf
commit b955d382e3

View File

@ -492,6 +492,9 @@
loadingCollectionKey: null, loadingCollectionKey: null,
nextCollectionItemsRequestToken: 0, nextCollectionItemsRequestToken: 0,
activeCollectionItemsRequestToken: 0, activeCollectionItemsRequestToken: 0,
hoveredItemKey: null,
hoverTimerId: null,
previewItemKey: null,
}; };
const elements = { const elements = {
@ -514,6 +517,7 @@
windowCollectionStatus: document.getElementById("window-collection-status"), windowCollectionStatus: document.getElementById("window-collection-status"),
windowCollectionTree: document.getElementById("window-collection-tree"), windowCollectionTree: document.getElementById("window-collection-tree"),
windowCollectionItems: document.getElementById("window-collection-items"), windowCollectionItems: document.getElementById("window-collection-items"),
previewPopover: document.getElementById("item-preview-popover"),
currentProjectLabel: document.getElementById("current-project-label"), currentProjectLabel: document.getElementById("current-project-label"),
cardList: document.getElementById("card-list"), cardList: document.getElementById("card-list"),
cardDetail: document.getElementById("card-detail"), cardDetail: document.getElementById("card-detail"),
@ -667,6 +671,20 @@
persistWindowSessionState(); persistWindowSessionState();
} }
function cancelAbstractPreview() {
if (state.hoverTimerId !== null) {
window.clearTimeout(state.hoverTimerId);
state.hoverTimerId = null;
}
state.hoveredItemKey = null;
state.previewItemKey = null;
elements.previewPopover.hidden = true;
elements.previewPopover.setAttribute("aria-hidden", "true");
elements.previewPopover.textContent = "";
elements.previewPopover.style.top = "";
elements.previewPopover.style.left = "";
}
function setStatus(target, message, isError = false) { function setStatus(target, message, isError = false) {
target.textContent = message || ""; target.textContent = message || "";
target.classList.toggle("error", Boolean(isError)); target.classList.toggle("error", Boolean(isError));