Skip to content

Commit 7a2f0d1

Browse files
kurowskiclaude
andcommitted
feat: hide section headings when only one list section exists
Only show "Local" and account name headings when there are multiple sections visible. Single-section views (e.g., only local lists or only one account) now appear without redundant headings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0bc4fc9 commit 7a2f0d1

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/lib/components/Sidebar.svelte

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@
8080
return { localLists, accountLists };
8181
});
8282
83+
// Show section headings only when there are multiple sections
84+
const showSectionHeadings = $derived(() => {
85+
const grouped = groupedLists();
86+
const hasLocalSection = preferencesStore.showLocalAccounts && grouped.localLists.length > 0;
87+
const accountCount = grouped.accountLists.size;
88+
const totalSections = (hasLocalSection ? 1 : 0) + accountCount;
89+
return totalSections >= 2;
90+
});
91+
8392
// Get account name by ID
8493
function getAccountName(accountId: number): string {
8594
const account = accountStore.accounts.find(a => a.id === accountId);
@@ -233,7 +242,9 @@
233242
<div class="list-nav">
234243
<!-- Local lists section -->
235244
{#if preferencesStore.showLocalAccounts && groupedLists().localLists.length > 0}
236-
<Subheader>Local</Subheader>
245+
{#if showSectionHeadings()}
246+
<Subheader>Local</Subheader>
247+
{/if}
237248
<List dense>
238249
{#each groupedLists().localLists as list (list.id)}
239250
{#if editingList?.id === list.id}
@@ -293,7 +304,9 @@
293304

294305
<!-- Account lists sections -->
295306
{#each [...groupedLists().accountLists.entries()] as [accountId, lists] (accountId)}
296-
<Subheader>{getAccountName(accountId)}</Subheader>
307+
{#if showSectionHeadings()}
308+
<Subheader>{getAccountName(accountId)}</Subheader>
309+
{/if}
297310
<List dense>
298311
{#each lists as list (list.id)}
299312
{#if editingList?.id === list.id}

0 commit comments

Comments
 (0)