fixed toc lag for card updates
This commit is contained in:
@@ -519,6 +519,35 @@ function scheduleSidebarErrors() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tocUpdateFrame = null;
|
||||||
|
function scheduleTocUpdate() {
|
||||||
|
if (!toc) return;
|
||||||
|
if (tocUpdateFrame) return;
|
||||||
|
tocUpdateFrame = requestAnimationFrame(() => {
|
||||||
|
tocUpdateFrame = null;
|
||||||
|
updateToc(collectWorkspaces(), collectSites());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const TOC_NAME_INPUT_SELECTOR = [
|
||||||
|
".api-key-name",
|
||||||
|
".api-config-name",
|
||||||
|
".env-config-name",
|
||||||
|
".profile-name",
|
||||||
|
".task-name",
|
||||||
|
".shortcut-name",
|
||||||
|
".workspace-name",
|
||||||
|
".site-name",
|
||||||
|
".site-pattern"
|
||||||
|
].join(", ");
|
||||||
|
|
||||||
|
function handleTocNameInput(event) {
|
||||||
|
const target = event.target;
|
||||||
|
if (!(target instanceof Element)) return;
|
||||||
|
if (!target.matches(TOC_NAME_INPUT_SELECTOR)) return;
|
||||||
|
scheduleTocUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
function renderGlobalSitesList(sites) {
|
function renderGlobalSitesList(sites) {
|
||||||
if (!globalSitesContainer) return;
|
if (!globalSitesContainer) return;
|
||||||
globalSitesContainer.innerHTML = "";
|
globalSitesContainer.innerHTML = "";
|
||||||
@@ -1230,6 +1259,7 @@ function updateApiConfigControls() {
|
|||||||
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
||||||
});
|
});
|
||||||
scheduleSidebarErrors();
|
scheduleSidebarErrors();
|
||||||
|
scheduleTocUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildApiKeyCard(entry) {
|
function buildApiKeyCard(entry) {
|
||||||
@@ -1404,6 +1434,7 @@ function updateApiKeyControls() {
|
|||||||
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
||||||
});
|
});
|
||||||
scheduleSidebarErrors();
|
scheduleSidebarErrors();
|
||||||
|
scheduleTocUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateApiConfigKeyOptions() {
|
function updateApiConfigKeyOptions() {
|
||||||
@@ -1630,6 +1661,7 @@ function updateEnvControls(container = envConfigsContainer) {
|
|||||||
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
||||||
});
|
});
|
||||||
scheduleSidebarErrors();
|
scheduleSidebarErrors();
|
||||||
|
scheduleTocUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTaskEnvOptionsForContainer(container, envs, allEnvsById) {
|
function updateTaskEnvOptionsForContainer(container, envs, allEnvsById) {
|
||||||
@@ -1879,6 +1911,7 @@ function updateProfileControls(container = profilesContainer) {
|
|||||||
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
||||||
});
|
});
|
||||||
scheduleSidebarErrors();
|
scheduleSidebarErrors();
|
||||||
|
scheduleTocUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTaskProfileOptionsForContainer(container, profiles, allProfilesById) {
|
function updateTaskProfileOptionsForContainer(container, profiles, allProfilesById) {
|
||||||
@@ -5034,6 +5067,7 @@ function updateShortcutControls(container = shortcutsContainer) {
|
|||||||
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
||||||
});
|
});
|
||||||
scheduleSidebarErrors();
|
scheduleSidebarErrors();
|
||||||
|
scheduleTocUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTaskControls(container = tasksContainer) {
|
function updateTaskControls(container = tasksContainer) {
|
||||||
@@ -5047,6 +5081,7 @@ function updateTaskControls(container = tasksContainer) {
|
|||||||
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
||||||
});
|
});
|
||||||
scheduleSidebarErrors();
|
scheduleSidebarErrors();
|
||||||
|
scheduleTocUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectTasks(container = tasksContainer) {
|
function collectTasks(container = tasksContainer) {
|
||||||
@@ -6117,6 +6152,9 @@ async function initSettings() {
|
|||||||
registerAllDetails();
|
registerAllDetails();
|
||||||
restoreScrollPosition();
|
restoreScrollPosition();
|
||||||
initDirtyObserver();
|
initDirtyObserver();
|
||||||
|
if (settingsLayout) {
|
||||||
|
settingsLayout.addEventListener("input", handleTocNameInput);
|
||||||
|
}
|
||||||
captureSavedSnapshot();
|
captureSavedSnapshot();
|
||||||
suppressDirtyTracking = false;
|
suppressDirtyTracking = false;
|
||||||
window.addEventListener("scroll", handleSettingsScroll, { passive: true });
|
window.addEventListener("scroll", handleSettingsScroll, { passive: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user