fix: fetch mailboxes on mount in FolderSettings when store is empty
This commit is contained in:
@@ -99,11 +99,17 @@ function IconPicker({ currentIcon, onSelect, onClose }: {
|
|||||||
export function FolderSettings() {
|
export function FolderSettings() {
|
||||||
const t = useTranslations('settings.folders');
|
const t = useTranslations('settings.folders');
|
||||||
const { client } = useAuthStore();
|
const { client } = useAuthStore();
|
||||||
const { mailboxes, createMailbox, renameMailbox, deleteMailbox, setMailboxRole } = useEmailStore();
|
const { mailboxes, fetchMailboxes, createMailbox, renameMailbox, deleteMailbox, setMailboxRole } = useEmailStore();
|
||||||
const { folderIcons, setFolderIcon } = useSettingsStore();
|
const { folderIcons, setFolderIcon } = useSettingsStore();
|
||||||
const { isFeatureEnabled } = usePolicyStore();
|
const { isFeatureEnabled } = usePolicyStore();
|
||||||
const folderIconsAllowed = isFeatureEnabled('folderIconsEnabled');
|
const folderIconsAllowed = isFeatureEnabled('folderIconsEnabled');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (client && mailboxes.length === 0) {
|
||||||
|
fetchMailboxes(client);
|
||||||
|
}
|
||||||
|
}, [client, mailboxes.length, fetchMailboxes]);
|
||||||
|
|
||||||
const [isCreating, setIsCreating] = useState(false);
|
const [isCreating, setIsCreating] = useState(false);
|
||||||
const [creatingParentId, setCreatingParentId] = useState<string | null>(null);
|
const [creatingParentId, setCreatingParentId] = useState<string | null>(null);
|
||||||
const [newFolderName, setNewFolderName] = useState('');
|
const [newFolderName, setNewFolderName] = useState('');
|
||||||
|
|||||||
Reference in New Issue
Block a user