From 0dfd7394302c52c2bec64b9203fba0955df680d1 Mon Sep 17 00:00:00 2001 From: cesnimda Date: Tue, 30 Jun 2026 20:45:48 +0200 Subject: [PATCH] feat: hide empty smart folders in sidebar Smart folders with zero matching emails are not rendered once sidebar counts have loaded. Folders still show while counts are pending (avoids flash of empty sidebar on load). Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/components/Layout.jsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Layout.jsx b/frontend/src/components/Layout.jsx index e445815..fa3c0f8 100644 --- a/frontend/src/components/Layout.jsx +++ b/frontend/src/components/Layout.jsx @@ -203,12 +203,14 @@ export default function Layout() { return fmtCount(item.countKey ? counts?.[item.countKey] : null); }; - // Smart folders sorted by count desc - const sortedSmart = [...SMART_FOLDERS].sort((a, b) => { - const ca = counts?.smartFolders?.[a.slug] ?? 0; - const cb = counts?.smartFolders?.[b.slug] ?? 0; - return cb - ca; - }); + // Smart folders sorted by count desc; hide empty ones once counts have loaded + const sortedSmart = [...SMART_FOLDERS] + .filter((f) => !counts || (counts.smartFolders?.[f.slug] ?? 0) > 0) + .sort((a, b) => { + const ca = counts?.smartFolders?.[a.slug] ?? 0; + const cb = counts?.smartFolders?.[b.slug] ?? 0; + return cb - ca; + }); const isPinnedSmart = (slug) => favSlugs.includes(slug);