fix regression trash shown on collection bar

This commit is contained in:
Abhinav 2022-07-05 00:42:56 +05:30
parent 409d83fafa
commit b3ba9ff56d
3 changed files with 19 additions and 13 deletions

View file

@ -13,7 +13,7 @@ import { AppContext } from 'pages/_app';
interface Iprops { interface Iprops {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
sortedCollectionSummaries: CollectionSummary[]; collectionSummaries: CollectionSummary[];
setActiveCollection: (id?: number) => void; setActiveCollection: (id?: number) => void;
collectionSortBy: COLLECTION_SORT_BY; collectionSortBy: COLLECTION_SORT_BY;
setCollectionSortBy: (v: COLLECTION_SORT_BY) => void; setCollectionSortBy: (v: COLLECTION_SORT_BY) => void;
@ -23,7 +23,7 @@ const LeftSlideTransition = Transition('up');
export default function AllCollections(props: Iprops) { export default function AllCollections(props: Iprops) {
const { const {
sortedCollectionSummaries, collectionSummaries,
open, open,
onClose, onClose,
setActiveCollection, setActiveCollection,
@ -46,13 +46,13 @@ export default function AllCollections(props: Iprops) {
fullScreen={isMobile}> fullScreen={isMobile}>
<AllCollectionsHeader <AllCollectionsHeader
onClose={onClose} onClose={onClose}
collectionCount={props.sortedCollectionSummaries.length} collectionCount={props.collectionSummaries.length}
collectionSortBy={collectionSortBy} collectionSortBy={collectionSortBy}
setCollectionSortBy={setCollectionSortBy} setCollectionSortBy={setCollectionSortBy}
/> />
<Divider /> <Divider />
<AllCollectionContent <AllCollectionContent
collectionSummaries={sortedCollectionSummaries} collectionSummaries={collectionSummaries}
onCollectionClick={onCollectionClick} onCollectionClick={onCollectionClick}
/> />
</AllCollectionDialog> </AllCollectionDialog>

View file

@ -20,7 +20,7 @@ import CollectionSort from '../AllCollections/CollectionSort';
interface IProps { interface IProps {
activeCollection?: number; activeCollection?: number;
setActiveCollection: (id?: number) => void; setActiveCollection: (id?: number) => void;
sortedCollectionSummaries: CollectionSummary[]; collectionSummaries: CollectionSummary[];
showAllCollections: () => void; showAllCollections: () => void;
collectionSortBy: COLLECTION_SORT_BY; collectionSortBy: COLLECTION_SORT_BY;
setCollectionSortBy: (v: COLLECTION_SORT_BY) => void; setCollectionSortBy: (v: COLLECTION_SORT_BY) => void;
@ -30,7 +30,7 @@ export default function CollectionListBar(props: IProps) {
const { const {
activeCollection, activeCollection,
setActiveCollection, setActiveCollection,
sortedCollectionSummaries, collectionSummaries,
showAllCollections, showAllCollections,
} = props; } = props;
@ -40,10 +40,10 @@ export default function CollectionListBar(props: IProps) {
const { componentRef, scrollComponent, onFarLeft, onFarRight } = const { componentRef, scrollComponent, onFarLeft, onFarRight } =
useComponentScroll({ useComponentScroll({
dependencies: [windowSize, sortedCollectionSummaries], dependencies: [windowSize, collectionSummaries],
}); });
const collectionChipsRef = sortedCollectionSummaries.reduce( const collectionChipsRef = collectionSummaries.reduce(
(refMap, collectionSummary) => { (refMap, collectionSummary) => {
refMap[collectionSummary.id] = React.createRef(); refMap[collectionSummary.id] = React.createRef();
return refMap; return refMap;
@ -85,7 +85,7 @@ export default function CollectionListBar(props: IProps) {
/> />
)} )}
<ScrollContainer ref={componentRef}> <ScrollContainer ref={componentRef}>
{sortedCollectionSummaries.map((item) => ( {collectionSummaries.map((item) => (
<CollectionListBarCard <CollectionListBarCard
key={item.id} key={item.id}
latestFile={item.latestFile} latestFile={item.latestFile}

View file

@ -7,7 +7,11 @@ import { ALL_SECTION, COLLECTION_SORT_BY } from 'constants/collection';
import CollectionShare from 'components/Collections/CollectionShare'; import CollectionShare from 'components/Collections/CollectionShare';
import { SetCollectionNamerAttributes } from 'components/Collections/CollectionNamer'; import { SetCollectionNamerAttributes } from 'components/Collections/CollectionNamer';
import { ITEM_TYPE, TimeStampListItem } from 'components/PhotoList'; import { ITEM_TYPE, TimeStampListItem } from 'components/PhotoList';
import { hasNonEmptyCollections, isSystemCollection } from 'utils/collection'; import {
hasNonEmptyCollections,
isSystemCollection,
shouldBeShownOnCollectionBar,
} from 'utils/collection';
import { useLocalState } from 'hooks/useLocalState'; import { useLocalState } from 'hooks/useLocalState';
import { sortCollectionSummaries } from 'services/collectionService'; import { sortCollectionSummaries } from 'services/collectionService';
import { LS_KEYS } from 'utils/storage/localStorage'; import { LS_KEYS } from 'utils/storage/localStorage';
@ -107,7 +111,9 @@ export default function Collections(props: Iprops) {
<CollectionListBar <CollectionListBar
activeCollection={activeCollectionID} activeCollection={activeCollectionID}
setActiveCollection={setActiveCollectionID} setActiveCollection={setActiveCollectionID}
sortedCollectionSummaries={sortedCollectionSummaries} collectionSummaries={sortedCollectionSummaries.filter((x) =>
shouldBeShownOnCollectionBar(x.type)
)}
showAllCollections={openAllCollections} showAllCollections={openAllCollections}
setCollectionSortBy={setCollectionSortBy} setCollectionSortBy={setCollectionSortBy}
collectionSortBy={collectionSortBy} collectionSortBy={collectionSortBy}
@ -116,8 +122,8 @@ export default function Collections(props: Iprops) {
<AllCollections <AllCollections
open={allCollectionView} open={allCollectionView}
onClose={closeAllCollections} onClose={closeAllCollections}
sortedCollectionSummaries={sortedCollectionSummaries.filter( collectionSummaries={sortedCollectionSummaries.filter((x) =>
(x) => !isSystemCollection(x.type) isSystemCollection(x.type)
)} )}
setActiveCollection={setActiveCollectionID} setActiveCollection={setActiveCollectionID}
setCollectionSortBy={setCollectionSortBy} setCollectionSortBy={setCollectionSortBy}