Skip to content

Commit

Permalink
Web: Files: fixed Paging re-render
Browse files Browse the repository at this point in the history
gopienkonikita committed Oct 28, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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
@@ -13,7 +13,7 @@ const SectionPagingContent = ({
selectedCount,
selectedFolderId,
tReady,
filterTotal,
totalPages,
}) => {
const { t } = useTranslation("Home");
const onNextClick = useCallback(
@@ -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,
@@ -116,7 +115,7 @@ const SectionPagingContent = ({
}),
};
});
}, [filterTotal, filter.pageCount, t]);
}, [filter.total, filter.pageCount, t, totalPages]);

const emptyPageSelection = {
key: 0,
@@ -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
@@ -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,

0 comments on commit a1d8a70

Please sign in to comment.