Skip to content

Commit

Permalink
fix: openIds usage
Browse files Browse the repository at this point in the history
  • Loading branch information
zovomat committed May 11, 2022
1 parent 3a13e7a commit f606a00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/views/sidebar/accordion-custom-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export const AccordionCustomComponent: FC<{ item: AccordionFolder }> = ({ item }
const [t] = useTranslation();
const dispatch = useDispatch();
const { folderId } = useParams<{ folderId: string }>();
const [openIds, setOpenIds] = useLocalStorage(
const [_, setOpenIds] = useLocalStorage(
'open_mails_folders',
window.localStorage.getItem('open_mails_folders') ?? []
);
Expand Down Expand Up @@ -519,12 +519,12 @@ export const AccordionCustomComponent: FC<{ item: AccordionFolder }> = ({ item }
label: item.id === FOLDERS.USER_ROOT ? accountName : item.label,
icon: getFolderIconName(item),
iconColor: getFolderIconColor(item),
open: openIds ? openIds.includes(folder.id) : false,
// open: openIds ? openIds.includes(folder.id) : false,
badgeCounter: badgeCount(item.id === FOLDERS.DRAFTS ? item?.folder.n : item?.folder?.u),
badgeType: item.id === FOLDERS.DRAFTS ? 'read' : 'unread',
to: `/folder/${item.id}`
}),
[item, accountName, openIds, folder.id]
[item, accountName]
);

const dropdownItems = useFolderActions(item);
Expand Down
15 changes: 13 additions & 2 deletions src/views/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import React, { useRef, FC, useContext } from 'react';
import { AccordionFolder, Folder, useFoldersAccordionByView } from '@zextras/carbonio-shell-ui';
import {
AccordionFolder,
Folder,
useFoldersAccordionByView,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
useLocalStorage
} from '@zextras/carbonio-shell-ui';
import { Accordion, Container, Button, ModalManagerContext } from '@zextras/carbonio-design-system';
import { Route, Switch, useRouteMatch, useParams } from 'react-router-dom';
import { useDispatch } from 'react-redux';
Expand All @@ -30,10 +37,14 @@ const SidebarComponent: FC<SidebarComponentProps> = ({ accordions }) => {
const createModal = useContext(ModalManagerContext) as Function;
const { folderId } = useParams<{ folderId: string }>();
const tagsAccordionItems = useGetTagsAccordion();
const [openIds] = useLocalStorage(
'open_mails_folders',
window.localStorage.getItem('open_mails_folders') ?? []
);

return (
<Container orientation="vertical" height="fit">
<Accordion ref={sidebarRef} items={accordions} activeId={folderId} />
<Accordion openIds={openIds} ref={sidebarRef} items={accordions} activeId={folderId} />
<Container style={{ padding: '8px 16px' }}>
<Button
type="outlined"
Expand Down

0 comments on commit f606a00

Please sign in to comment.