Removed UNCATEGORIZED_SECTION constant and implemented uncategorized count in side pannel
This commit is contained in:
parent
b8faf0d22d
commit
3aa3e6b22b
|
@ -1,11 +1,7 @@
|
|||
import React, { useContext } from 'react';
|
||||
import React, { useContext, useRef, useEffect } from 'react';
|
||||
import constants from 'utils/strings/constants';
|
||||
import { GalleryContext } from 'pages/gallery';
|
||||
import {
|
||||
ARCHIVE_SECTION,
|
||||
TRASH_SECTION,
|
||||
UNCATEGORIZED_SECTION,
|
||||
} from 'constants/collection';
|
||||
import { ARCHIVE_SECTION, TRASH_SECTION } from 'constants/collection';
|
||||
import { CollectionSummaries } from 'types/collection';
|
||||
import ShortcutButton from './ShortcutButton';
|
||||
import DeleteOutline from '@mui/icons-material/DeleteOutline';
|
||||
|
@ -22,10 +18,23 @@ export default function ShortcutSection({
|
|||
collectionSummaries,
|
||||
}: Iprops) {
|
||||
const galleryContext = useContext(GalleryContext);
|
||||
const unCategorizedCollectionId = useRef(0);
|
||||
useEffect(() => {
|
||||
const UncategorizedSection = async () => {
|
||||
const uncategorisedCollection = await getUncategorizedCollection();
|
||||
unCategorizedCollectionId.current = uncategorisedCollection.id;
|
||||
console.log(unCategorizedCollectionId.current);
|
||||
console.log('hi');
|
||||
};
|
||||
return () => {
|
||||
UncategorizedSection;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const openUncategorizedSection = async () => {
|
||||
const uncategorisedCollection = await getUncategorizedCollection();
|
||||
galleryContext.setActiveCollection(uncategorisedCollection.id);
|
||||
unCategorizedCollectionId.current = uncategorisedCollection.id;
|
||||
galleryContext.setActiveCollection(unCategorizedCollectionId.current);
|
||||
closeSidebar();
|
||||
};
|
||||
|
||||
|
@ -38,16 +47,16 @@ export default function ShortcutSection({
|
|||
galleryContext.setActiveCollection(ARCHIVE_SECTION);
|
||||
closeSidebar();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<ShortcutButton
|
||||
startIcon={<CategoryIcon />}
|
||||
label={constants.UNCATEGORIZED}
|
||||
count={
|
||||
collectionSummaries.get(UNCATEGORIZED_SECTION)?.fileCount
|
||||
}
|
||||
onClick={openUncategorizedSection}
|
||||
count={
|
||||
collectionSummaries.get(unCategorizedCollectionId.current)
|
||||
.fileCount
|
||||
}
|
||||
/>
|
||||
<ShortcutButton
|
||||
startIcon={<DeleteOutline />}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
export const UNCATEGORIZED_SECTION = -1;
|
||||
export const ARCHIVE_SECTION = -2;
|
||||
export const TRASH_SECTION = -3;
|
||||
export const ARCHIVE_SECTION = -1;
|
||||
export const TRASH_SECTION = -2;
|
||||
export const ALL_SECTION = 0;
|
||||
export enum CollectionType {
|
||||
folder = 'folder',
|
||||
|
|
|
@ -59,7 +59,6 @@ import PlanSelector from 'components/pages/gallery/PlanSelector';
|
|||
import Uploader from 'components/Upload/Uploader';
|
||||
import {
|
||||
ALL_SECTION,
|
||||
UNCATEGORIZED_SECTION,
|
||||
ARCHIVE_SECTION,
|
||||
CollectionType,
|
||||
TRASH_SECTION,
|
||||
|
@ -314,9 +313,7 @@ export default function Gallery() {
|
|||
let collectionURL = '';
|
||||
if (activeCollection !== ALL_SECTION) {
|
||||
collectionURL += '?collection=';
|
||||
if (activeCollection === UNCATEGORIZED_SECTION) {
|
||||
collectionURL += constants.UNCATEGORIZED;
|
||||
} else if (activeCollection === ARCHIVE_SECTION) {
|
||||
if (activeCollection === ARCHIVE_SECTION) {
|
||||
collectionURL += constants.ARCHIVE;
|
||||
} else if (activeCollection === TRASH_SECTION) {
|
||||
collectionURL += constants.TRASH;
|
||||
|
|
Loading…
Reference in a new issue