sort collection bar collection summaries

This commit is contained in:
Abhinav 2022-06-03 13:42:42 +05:30
parent ed54ede6d7
commit 594c9ad5df
2 changed files with 23 additions and 13 deletions

View file

@ -1,8 +1,8 @@
import ScrollButton from 'components/Collections/CollectionBar/ScrollButton';
import React, { useEffect } from 'react';
import React, { useEffect, useMemo } from 'react';
import { Collection, CollectionSummaries } from 'types/collection';
import constants from 'utils/strings/constants';
import { ALL_SECTION } from 'constants/collection';
import { ALL_SECTION, COLLECTION_SORT_BY } from 'constants/collection';
import { Typography } from '@mui/material';
import {
Hider,
@ -15,6 +15,7 @@ import useComponentScroll, { SCROLL_DIRECTION } from 'hooks/useComponentScroll';
import useWindowSize from 'hooks/useWindowSize';
import LinkButton from 'components/pages/gallery/LinkButton';
import { SpaceBetweenFlex } from 'components/Container';
import { sortCollectionSummaries } from 'services/collectionService';
interface IProps {
collections: Collection[];
@ -34,7 +35,17 @@ export default function CollectionBar(props: IProps) {
showAllCollections,
} = props;
const sortedCollectionSummary = useMemo(
() =>
sortCollectionSummaries(
[...collectionSummaries.values()],
COLLECTION_SORT_BY.UPDATION_TIME_DESCENDING
),
[collectionSummaries]
);
const windowSize = useWindowSize();
const {
componentRef,
scrollComponent,
@ -90,15 +101,13 @@ export default function CollectionBar(props: IProps) {
onClick={clickHandler(ALL_SECTION)}>
{constants.ALL_SECTION_NAME}
</CollectionCardWithActiveIndicator>
{collections.map((item) => (
{sortedCollectionSummary.map((item) => (
<CollectionCardWithActiveIndicator
key={item.id}
latestFile={
collectionSummaries.get(item.id)?.latestFile
}
ref={collectionChipsRef[item.id]}
active={activeCollection === item.id}
onClick={clickHandler(item.id)}>
key={item.attributes.id}
latestFile={item.latestFile}
ref={collectionChipsRef[item.attributes.id]}
active={activeCollection === item.attributes.id}
onClick={clickHandler(item.attributes.id)}>
{item.name}
</CollectionCardWithActiveIndicator>
))}

View file

@ -28,7 +28,8 @@ export default function collectionInfoWithOptions({
<CollectionSectionWrapper>
<SpaceBetweenFlex>
<CollectionInfo name={name} fileCount={fileCount} />
{type !== CollectionType.system && (
{type !== CollectionType.system &&
type !== CollectionType.favorites && (
<CollectionOptions {...props} />
)}
</SpaceBetweenFlex>