fix: defer icon sets panel creation until first settings section expand
Previously iconSetsPanel() was called eagerly on settings render, triggering a GET /api/icon-sets request even while the section was collapsed. Now the panel is created and appended on first toggle-open, with subsequent clicks toggling display as before. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -101,16 +101,22 @@ export async function render(main) {
|
|||||||
const tokensBody = el('div', { class: 'settings-body' });
|
const tokensBody = el('div', { class: 'settings-body' });
|
||||||
const agentsBody = el('div', { class: 'settings-body' });
|
const agentsBody = el('div', { class: 'settings-body' });
|
||||||
|
|
||||||
// Icon sets — collapsible; panel is lazy-created once but hidden by default.
|
// Icon sets — collapsible; panel is lazy-created on first expand so
|
||||||
const isPanel = iconSetsPanel();
|
// /api/icon-sets is not fetched while the section is collapsed.
|
||||||
isPanel.style.display = 'none';
|
let isPanel = null;
|
||||||
|
const iconSetsWrap = el('div', { class: 'settings-body' });
|
||||||
const isToggle = el('button', { class: 'ghost' }, '▸ Icon sets');
|
const isToggle = el('button', { class: 'ghost' }, '▸ Icon sets');
|
||||||
isToggle.addEventListener('click', () => {
|
isToggle.addEventListener('click', () => {
|
||||||
|
if (!isPanel) {
|
||||||
|
// First expand: create and append the panel.
|
||||||
|
isPanel = iconSetsPanel();
|
||||||
|
iconSetsWrap.appendChild(isPanel);
|
||||||
|
}
|
||||||
const open = isPanel.style.display !== 'none';
|
const open = isPanel.style.display !== 'none';
|
||||||
isPanel.style.display = open ? 'none' : 'block';
|
isPanel.style.display = open ? 'none' : 'block';
|
||||||
isToggle.textContent = (open ? '▸' : '▾') + ' Icon sets';
|
isToggle.textContent = (open ? '▸' : '▾') + ' Icon sets';
|
||||||
});
|
});
|
||||||
const iconSetsWrap = el('div', { class: 'settings-body' }, isToggle, isPanel);
|
iconSetsWrap.appendChild(isToggle);
|
||||||
|
|
||||||
mount(main,
|
mount(main,
|
||||||
el('h1', { class: 'view-h1' }, '◆ Settings'),
|
el('h1', { class: 'view-h1' }, '◆ Settings'),
|
||||||
|
|||||||
Reference in New Issue
Block a user