(null);
const goToDefaultFolder = () => {
- const defaultFolder = MAILBOX_FOLDERS[0];
+ const defaultFolder = MAILBOX_FOLDERS()[0];
router.push(pathname + `?${new URLSearchParams(defaultFolder.filter).toString()}`);
}
const moveLabelMutation = useLabelsPartialUpdate();
diff --git a/src/frontend/src/features/layouts/components/mailbox-panel/components/mailbox-list/index.tsx b/src/frontend/src/features/layouts/components/mailbox-panel/components/mailbox-list/index.tsx
index 54028dc6..c0103859 100644
--- a/src/frontend/src/features/layouts/components/mailbox-panel/components/mailbox-list/index.tsx
+++ b/src/frontend/src/features/layouts/components/mailbox-panel/components/mailbox-list/index.tsx
@@ -18,7 +18,7 @@ type Folder = {
searchable?: boolean;
}
-export const MAILBOX_FOLDERS: Folder[] = [
+export const MAILBOX_FOLDERS = (): Folder[] => [
{
id: "inbox",
name: i18n.t("Inbox"),
@@ -81,12 +81,13 @@ export const MAILBOX_FOLDERS: Folder[] = [
// is_spam: "1",
// },
// },
-]
+];
export const MailboxList = () => {
+
return (
- {MAILBOX_FOLDERS.map((folder) => (
+ {MAILBOX_FOLDERS().map((folder) => (
{
// Only show import button if there are no threads in inbox or all messages folders and user has ability to import messages
if (!canImportMessages) return false;
if (threads?.results.length) return false;
- const importableMessageFolders = MAILBOX_FOLDERS.filter((folder) => ['inbox', 'all_messages'].includes(folder.id));
+ const importableMessageFolders = MAILBOX_FOLDERS().filter((folder) => ['inbox', 'all_messages'].includes(folder.id));
return importableMessageFolders.some((folder) => searchParams.toString() === new URLSearchParams(folder.filter).toString());
}, [canImportMessages, threads?.results, searchParams]);
diff --git a/src/frontend/src/features/providers/mailbox.tsx b/src/frontend/src/features/providers/mailbox.tsx
index 67334185..398b6e30 100644
--- a/src/frontend/src/features/providers/mailbox.tsx
+++ b/src/frontend/src/features/providers/mailbox.tsx
@@ -318,7 +318,7 @@ export const MailboxProvider = ({ children }: PropsWithChildren) => {
useEffect(() => {
if (selectedMailbox) {
if (router.pathname === '/' || (selectedMailbox.id !== router.query.mailboxId && !router.pathname.includes('new'))) {
- const defaultFolder = MAILBOX_FOLDERS[0];
+ const defaultFolder = MAILBOX_FOLDERS()[0];
const hash = window.location.hash;
if (router.query.threadId) {
router.replace(`/mailbox/${selectedMailbox.id}/thread/${router.query.threadId}?${router.query.search}${hash}`);
diff --git a/src/frontend/src/pages/mailbox/[mailboxId]/new/index.tsx b/src/frontend/src/pages/mailbox/[mailboxId]/new/index.tsx
index 06445a30..8ee781eb 100644
--- a/src/frontend/src/pages/mailbox/[mailboxId]/new/index.tsx
+++ b/src/frontend/src/pages/mailbox/[mailboxId]/new/index.tsx
@@ -21,7 +21,7 @@ const NewMessageFormPage = () => {
} else if (!selectedMailbox) {
router.push('/');
} else {
- const defaultFolder = MAILBOX_FOLDERS[0];
+ const defaultFolder = MAILBOX_FOLDERS()[0];
router.push(`/mailbox/${selectedMailbox.id}` + `?${new URLSearchParams(defaultFolder.filter).toString()}`);
}
}