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 constants from 'utils/strings/constants';
|
||||||
import { GalleryContext } from 'pages/gallery';
|
import { GalleryContext } from 'pages/gallery';
|
||||||
import {
|
import { ARCHIVE_SECTION, TRASH_SECTION } from 'constants/collection';
|
||||||
ARCHIVE_SECTION,
|
|
||||||
TRASH_SECTION,
|
|
||||||
UNCATEGORIZED_SECTION,
|
|
||||||
} from 'constants/collection';
|
|
||||||
import { CollectionSummaries } from 'types/collection';
|
import { CollectionSummaries } from 'types/collection';
|
||||||
import ShortcutButton from './ShortcutButton';
|
import ShortcutButton from './ShortcutButton';
|
||||||
import DeleteOutline from '@mui/icons-material/DeleteOutline';
|
import DeleteOutline from '@mui/icons-material/DeleteOutline';
|
||||||
|
@ -22,10 +18,23 @@ export default function ShortcutSection({
|
||||||
collectionSummaries,
|
collectionSummaries,
|
||||||
}: Iprops) {
|
}: Iprops) {
|
||||||
const galleryContext = useContext(GalleryContext);
|
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 openUncategorizedSection = async () => {
|
||||||
const uncategorisedCollection = await getUncategorizedCollection();
|
const uncategorisedCollection = await getUncategorizedCollection();
|
||||||
galleryContext.setActiveCollection(uncategorisedCollection.id);
|
unCategorizedCollectionId.current = uncategorisedCollection.id;
|
||||||
|
galleryContext.setActiveCollection(unCategorizedCollectionId.current);
|
||||||
closeSidebar();
|
closeSidebar();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,16 +47,16 @@ export default function ShortcutSection({
|
||||||
galleryContext.setActiveCollection(ARCHIVE_SECTION);
|
galleryContext.setActiveCollection(ARCHIVE_SECTION);
|
||||||
closeSidebar();
|
closeSidebar();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ShortcutButton
|
<ShortcutButton
|
||||||
startIcon={<CategoryIcon />}
|
startIcon={<CategoryIcon />}
|
||||||
label={constants.UNCATEGORIZED}
|
label={constants.UNCATEGORIZED}
|
||||||
count={
|
|
||||||
collectionSummaries.get(UNCATEGORIZED_SECTION)?.fileCount
|
|
||||||
}
|
|
||||||
onClick={openUncategorizedSection}
|
onClick={openUncategorizedSection}
|
||||||
|
count={
|
||||||
|
collectionSummaries.get(unCategorizedCollectionId.current)
|
||||||
|
.fileCount
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<ShortcutButton
|
<ShortcutButton
|
||||||
startIcon={<DeleteOutline />}
|
startIcon={<DeleteOutline />}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
export const UNCATEGORIZED_SECTION = -1;
|
export const ARCHIVE_SECTION = -1;
|
||||||
export const ARCHIVE_SECTION = -2;
|
export const TRASH_SECTION = -2;
|
||||||
export const TRASH_SECTION = -3;
|
|
||||||
export const ALL_SECTION = 0;
|
export const ALL_SECTION = 0;
|
||||||
export enum CollectionType {
|
export enum CollectionType {
|
||||||
folder = 'folder',
|
folder = 'folder',
|
||||||
|
|
|
@ -59,7 +59,6 @@ import PlanSelector from 'components/pages/gallery/PlanSelector';
|
||||||
import Uploader from 'components/Upload/Uploader';
|
import Uploader from 'components/Upload/Uploader';
|
||||||
import {
|
import {
|
||||||
ALL_SECTION,
|
ALL_SECTION,
|
||||||
UNCATEGORIZED_SECTION,
|
|
||||||
ARCHIVE_SECTION,
|
ARCHIVE_SECTION,
|
||||||
CollectionType,
|
CollectionType,
|
||||||
TRASH_SECTION,
|
TRASH_SECTION,
|
||||||
|
@ -314,9 +313,7 @@ export default function Gallery() {
|
||||||
let collectionURL = '';
|
let collectionURL = '';
|
||||||
if (activeCollection !== ALL_SECTION) {
|
if (activeCollection !== ALL_SECTION) {
|
||||||
collectionURL += '?collection=';
|
collectionURL += '?collection=';
|
||||||
if (activeCollection === UNCATEGORIZED_SECTION) {
|
if (activeCollection === ARCHIVE_SECTION) {
|
||||||
collectionURL += constants.UNCATEGORIZED;
|
|
||||||
} else if (activeCollection === ARCHIVE_SECTION) {
|
|
||||||
collectionURL += constants.ARCHIVE;
|
collectionURL += constants.ARCHIVE;
|
||||||
} else if (activeCollection === TRASH_SECTION) {
|
} else if (activeCollection === TRASH_SECTION) {
|
||||||
collectionURL += constants.TRASH;
|
collectionURL += constants.TRASH;
|
||||||
|
|
Loading…
Reference in a new issue