From 6524204b2d5d4bc64ab26d7632afcd0166fcafbc Mon Sep 17 00:00:00 2001 From: abhinav-grd Date: Wed, 22 Sep 2021 10:37:08 +0530 Subject: [PATCH] set active collection to 0 for all section --- src/components/pages/gallery/Collections.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/pages/gallery/Collections.tsx b/src/components/pages/gallery/Collections.tsx index a3bf0ffb0..0a50e75f9 100644 --- a/src/components/pages/gallery/Collections.tsx +++ b/src/components/pages/gallery/Collections.tsx @@ -15,6 +15,8 @@ import { SetCollectionNamerAttributes } from './CollectionNamer'; import CollectionOptions from './CollectionOptions'; import OptionIcon, { OptionIconWrapper } from './OptionIcon'; +export const ALL_SECTION = 0; + interface CollectionProps { collections: Collection[]; selected?: number; @@ -100,9 +102,9 @@ export default function Collections(props: CollectionProps) { collectionRef.current.scrollLeft = 0; }, [collections]); - const clickHandler = (collection?: Collection) => () => { - setSelectedCollectionID(collection?.id); - setActiveCollection(collection?.id); + const clickHandler = (collectionID?: number) => () => { + setSelectedCollectionID(collectionID); + setActiveCollection(collectionID ?? ALL_SECTION); }; const user: User = getData(LS_KEYS.USER); @@ -119,7 +121,7 @@ export default function Collections(props: CollectionProps) { setDialogMessage: props.setDialogMessage, startLoadingBar: props.startLoadingBar, showCollectionShareModal: setCollectionShareModalView.bind(null, true), - redirectToAll: setActiveCollection.bind(null, 0), + redirectToAll: setActiveCollection.bind(null, ALL_SECTION), }); const scrollCollection = (direction: SCROLL_DIRECTION) => () => { @@ -171,7 +173,9 @@ export default function Collections(props: CollectionProps) { /> )} - + All
+ onClick={clickHandler(item.id)}> {item.name} {item.type !== CollectionType.favorites && item.owner.id === user?.id ? (