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 6d62e54 commit dcb8f10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const StyledSectionPaging = styled.div`
`;

class SectionPaging extends React.Component {
shouldComponentUpdate(nextProps) {
return !equal(this.props, nextProps);
}
// shouldComponentUpdate(nextProps) {
// return !equal(this.props, nextProps);
// }

render() {
return <StyledSectionPaging {...this.props} />;
Expand Down
12 changes: 7 additions & 5 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,6 +13,7 @@ const SectionPagingContent = ({
selectedCount,
selectedFolderId,
tReady,
filterTotal,
}) => {
const { t } = useTranslation("Home");
const onNextClick = useCallback(
Expand Down Expand Up @@ -104,8 +105,8 @@ const SectionPagingContent = ({
);

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

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

return !tReady || (filter.total < filter.pageCount && filter.total < 26) ? (
return !tReady || (filterTotal < filter.pageCount && filterTotal < 26) ? (
<></>
) : (
<Paging
Expand Down Expand Up @@ -173,6 +174,7 @@ export default inject(({ filesStore, selectedFolderStore }) => {
folders,
selectedFolderId: selectedFolderStore.id,
filter,
filterTotal: filter.total,

setIsLoading,
fetchFiles,
Expand Down

0 comments on commit dcb8f10

Please sign in to comment.