Refactor and fix sorting in library (#197)

This commit is contained in:
Valter Martinek
2022-11-24 21:04:30 +01:00
committed by GitHub
parent 154b357c40
commit 62816338f3
5 changed files with 75 additions and 76 deletions

View File

@@ -26,12 +26,14 @@ export interface IMangaGridProps{
gridLayout?: number | undefined
horisontal?: boolean | undefined
noFaces?: boolean | undefined
inLibraryIndicator?: boolean
}
export default function MangaGrid(props: IMangaGridProps) {
const MangaGrid: React.FC<IMangaGridProps> = (props) => {
const {
mangas, isLoading, message, messageExtra,
hasNextPage, lastPageNum, setLastPageNum, gridLayout, horisontal, noFaces,
inLibraryIndicator,
} = props;
let mapped;
const lastManga = useRef<HTMLDivElement>(null);
@@ -90,27 +92,16 @@ export default function MangaGrid(props: IMangaGridProps) {
);
}
} else {
mapped = mangas.map((it, idx) => {
if (idx === mangas.length - 1) {
return (
<MangaCard
key={it.id}
manga={it}
ref={lastManga}
gridLayout={gridLayout}
dimensions={dimensions}
/>
);
}
return (
<MangaCard
key={it.id}
manga={it}
gridLayout={gridLayout}
dimensions={dimensions}
/>
);
});
mapped = mangas.map((it, idx) => (
<MangaCard
key={it.id}
manga={it}
ref={idx === mangas.length - 1 ? lastManga : undefined}
gridLayout={gridLayout}
dimensions={dimensions}
inLibraryIndicator={inLibraryIndicator}
/>
));
}
return (
@@ -135,9 +126,11 @@ export default function MangaGrid(props: IMangaGridProps) {
</Grid>
</div>
);
}
};
MangaGrid.defaultProps = {
message: '',
messageExtra: undefined,
};
export default MangaGrid;