Browse Source

fix: remove unnecessary pagination

develop
Ezerous 4 years ago
parent
commit
ee23e461c1
  1. 27
      packages/concordia-app/src/components/PostList/index.jsx
  2. 11
      packages/concordia-app/src/components/TopicList/index.jsx

27
packages/concordia-app/src/components/PostList/index.jsx

@ -52,10 +52,24 @@ const PostList = (props) => {
}); });
}, [focusOnPost, getPostCallHashes, loading, pageNumber, postIds]); }, [focusOnPost, getPostCallHashes, loading, pageNumber, postIds]);
const handlePageChange = (event, data) => { const footer = useMemo(() => {
setPageNumber(data.activePage); const handlePageChange = (event, data) => {
onPageChange(event, data); setPageNumber(data.activePage);
}; onPageChange(event, data);
};
if (numberOfItems <= ITEMS_PER_PAGE) {
return null;
}
return (
<>
<Divider />
<div id="post-list-pagination">
<PaginationComponent onPageChange={handlePageChange} numberOfItems={numberOfItems} />
</div>
</>
);
}, [numberOfItems, onPageChange]);
return ( return (
<> <>
@ -63,10 +77,7 @@ const PostList = (props) => {
<Loader active={loading} /> <Loader active={loading} />
{posts} {posts}
</Dimmer.Dimmable> </Dimmer.Dimmable>
<Divider /> {footer}
<div id="post-list-pagination">
<PaginationComponent onPageChange={handlePageChange} numberOfItems={numberOfItems} />
</div>
</> </>
); );
}; };

11
packages/concordia-app/src/components/TopicList/index.jsx

@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import { List } from 'semantic-ui-react'; import { List } from 'semantic-ui-react';
import { FORUM_CONTRACT } from 'concordia-shared/src/constants/contracts/ContractNames'; import { FORUM_CONTRACT } from 'concordia-shared/src/constants/contracts/ContractNames';
import TopicListRow from './TopicListRow'; import TopicListRow from './TopicListRow';
import PaginationComponent from '../PaginationComponent'; import PaginationComponent, { ITEMS_PER_PAGE } from '../PaginationComponent';
import { drizzle } from '../../redux/store'; import { drizzle } from '../../redux/store';
import './styles.css'; import './styles.css';
@ -39,12 +39,19 @@ const TopicList = (props) => {
); );
}), [getTopicCallHashes, topicIds]); }), [getTopicCallHashes, topicIds]);
const pagination = useMemo(() => {
if (numberOfItems <= ITEMS_PER_PAGE) {
return null;
}
return (<PaginationComponent onPageChange={onPageChange} numberOfItems={numberOfItems} />);
}, [numberOfItems, onPageChange]);
return ( return (
<div> <div>
<List id="topic-list" size="big"> <List id="topic-list" size="big">
{topics} {topics}
</List> </List>
<PaginationComponent onPageChange={onPageChange} numberOfItems={numberOfItems} /> {pagination}
</div> </div>
); );
}; };

Loading…
Cancel
Save