mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Fix followers pagination UI
This commit is contained in:
parent
e443188cbc
commit
14f405bf58
@ -22,27 +22,28 @@ export default class FollowerList extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
async getFollowers() {
|
||||
const { currentPage } = this.state;
|
||||
async getFollowers(requestedPage) {
|
||||
const limit = 24;
|
||||
const offset = currentPage * limit;
|
||||
const u = `${URL_FOLLOWERS}?offset=${offset}&limit=${limit}`;
|
||||
const offset = requestedPage * limit;
|
||||
const u = `${URL_FOLLOWERS}?offset=${offset || 0}&limit=${limit}`;
|
||||
const response = await fetch(u);
|
||||
const followers = await response.json();
|
||||
const pages = Math.ceil(followers.total / limit);
|
||||
|
||||
this.setState({
|
||||
followers: followers.results,
|
||||
total: response.total,
|
||||
total: followers.total,
|
||||
pages: pages,
|
||||
});
|
||||
}
|
||||
|
||||
changeFollowersPage(page) {
|
||||
this.setState({ currentPage: page });
|
||||
this.getFollowers();
|
||||
changeFollowersPage(requestedPage) {
|
||||
this.setState({ currentPage: requestedPage });
|
||||
this.getFollowers(requestedPage);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { followers, total, currentPage } = this.state;
|
||||
const { followers, total, pages, currentPage } = this.state;
|
||||
if (!followers) {
|
||||
return null;
|
||||
}
|
||||
@ -62,8 +63,8 @@ export default class FollowerList extends Component {
|
||||
</div>`;
|
||||
|
||||
const paginationControls =
|
||||
total > 1 &&
|
||||
Array(total)
|
||||
pages > 1 &&
|
||||
Array(pages)
|
||||
.fill()
|
||||
.map((x, n) => {
|
||||
const activePageClass =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user