From 8c575e8ed817ad833e21d35976ff828211891a28 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Wed, 24 Jun 2026 18:20:52 +0200 Subject: [PATCH] fix: load mailboxes in Filters when opened directly #485 --- components/settings/filter-settings.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/settings/filter-settings.tsx b/components/settings/filter-settings.tsx index d011952e..259f7705 100644 --- a/components/settings/filter-settings.tsx +++ b/components/settings/filter-settings.tsx @@ -160,6 +160,7 @@ export function FilterSettings() { const tNotifications = useTranslations("notifications"); const { client } = useAuthStore(); const storeMailboxes = useEmailStore((s) => s.mailboxes); + const fetchMailboxes = useEmailStore((s) => s.fetchMailboxes); const expandedFilterView = useSettingsStore((s) => s.expandedFilterView); const updateSetting = useSettingsStore((s) => s.updateSetting); @@ -212,6 +213,22 @@ export function FilterSettings() { return () => { cancelled = true; }; }, [client, managedAccountId]); + // The "move to" folder list for the primary account comes from the email + // store, which is normally populated when the mail view mounts. When the app + // is opened or refreshed directly on Settings (the mail view never mounted), + // that store is empty, leaving the rule editor's folder dropdown blank. Fetch + // mailboxes on demand here so Filters never depends on having visited Inbox + // first. fetchMailboxes guards against transient empty results and selecting + // an inbox, so it's safe to call independently; a ref keeps it to one attempt + // per client. + const primaryFetchClientRef = useRef(null); + useEffect(() => { + if (managedAccountId || !client || storeMailboxes.length > 0) return; + if (primaryFetchClientRef.current === client) return; + primaryFetchClientRef.current = client; + void fetchMailboxes(client); + }, [client, managedAccountId, storeMailboxes.length, fetchMailboxes]); + const mailboxes = managedAccountId ? scopedMailboxes : storeMailboxes; const vacationStoreEnabled = useVacationStore((s) => s.isEnabled);