Browse Source

fix: remove unnecessary pagination

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

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

@ -52,23 +52,34 @@ const PostList = (props) => {
}); });
}, [focusOnPost, getPostCallHashes, loading, pageNumber, postIds]); }, [focusOnPost, getPostCallHashes, loading, pageNumber, postIds]);
const footer = useMemo(() => {
const handlePageChange = (event, data) => { const handlePageChange = (event, data) => {
setPageNumber(data.activePage); setPageNumber(data.activePage);
onPageChange(event, data); onPageChange(event, data);
}; };
if (numberOfItems <= ITEMS_PER_PAGE) {
return null;
}
return ( return (
<> <>
<Dimmer.Dimmable as={Feed} blurring dimmed={loading} id="post-list" size="large">
<Loader active={loading} />
{posts}
</Dimmer.Dimmable>
<Divider /> <Divider />
<div id="post-list-pagination"> <div id="post-list-pagination">
<PaginationComponent onPageChange={handlePageChange} numberOfItems={numberOfItems} /> <PaginationComponent onPageChange={handlePageChange} numberOfItems={numberOfItems} />
</div> </div>
</> </>
); );
}, [numberOfItems, onPageChange]);
return (
<>
<Dimmer.Dimmable as={Feed} blurring dimmed={loading} id="post-list" size="large">
<Loader active={loading} />
{posts}
</Dimmer.Dimmable>
{footer}
</>
);
}; };
PostList.propTypes = { PostList.propTypes = {

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