Skip to content

Commit

Permalink
Web: Files: fixed Paging re-render
Browse files Browse the repository at this point in the history
  • Loading branch information
gopienkonikita committed Oct 28, 2021
1 parent dcb8f10 commit a1d8a70
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions products/ASC.Files/Client/src/pages/Home/Section/Paging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const SectionPagingContent = ({
selectedCount,
selectedFolderId,
tReady,
filterTotal,
totalPages,
}) => {
const { t } = useTranslation("Home");
const onNextClick = useCallback(
Expand Down Expand Up @@ -105,8 +105,7 @@ const SectionPagingContent = ({
);

const pageItems = useMemo(() => {
if (filterTotal < filter.pageCount) return [];
const totalPages = Math.ceil(filterTotal / filter.pageCount);
if (filter.total < filter.pageCount) return [];
return [...Array(totalPages).keys()].map((item) => {
return {
key: item,
Expand All @@ -116,7 +115,7 @@ const SectionPagingContent = ({
}),
};
});
}, [filterTotal, filter.pageCount, t]);
}, [filter.total, filter.pageCount, t, totalPages]);

const emptyPageSelection = {
key: 0,
Expand All @@ -138,11 +137,11 @@ const SectionPagingContent = ({
const showCountItem = useMemo(() => {
if (files && folders)
return (
files.length + folders.length === filter.pageCount || filterTotal > 25
files.length + folders.length === filter.pageCount || filter.total > 25
);
}, [files, folders, filter, pageItems]);

return !tReady || (filterTotal < filter.pageCount && filterTotal < 26) ? (
return !tReady || (filter.total < filter.pageCount && filter.total < 26) ? (
<></>
) : (
<Paging
Expand All @@ -169,12 +168,14 @@ const SectionPagingContent = ({
export default inject(({ filesStore, selectedFolderStore }) => {
const { files, folders, fetchFiles, filter, setIsLoading } = filesStore;

const totalPages = Math.ceil(filter.total / filter.pageCount);

return {
files,
folders,
selectedFolderId: selectedFolderStore.id,
filter,
filterTotal: filter.total,
totalPages,

setIsLoading,
fetchFiles,
Expand Down

0 comments on commit a1d8a70

Please sign in to comment.