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() {
|
async getFollowers(requestedPage) {
|
||||||
const { currentPage } = this.state;
|
|
||||||
const limit = 24;
|
const limit = 24;
|
||||||
const offset = currentPage * limit;
|
const offset = requestedPage * limit;
|
||||||
const u = `${URL_FOLLOWERS}?offset=${offset}&limit=${limit}`;
|
const u = `${URL_FOLLOWERS}?offset=${offset || 0}&limit=${limit}`;
|
||||||
const response = await fetch(u);
|
const response = await fetch(u);
|
||||||
const followers = await response.json();
|
const followers = await response.json();
|
||||||
|
const pages = Math.ceil(followers.total / limit);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
followers: followers.results,
|
followers: followers.results,
|
||||||
total: response.total,
|
total: followers.total,
|
||||||
|
pages: pages,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
changeFollowersPage(page) {
|
changeFollowersPage(requestedPage) {
|
||||||
this.setState({ currentPage: page });
|
this.setState({ currentPage: requestedPage });
|
||||||
this.getFollowers();
|
this.getFollowers(requestedPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { followers, total, currentPage } = this.state;
|
const { followers, total, pages, currentPage } = this.state;
|
||||||
if (!followers) {
|
if (!followers) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -62,8 +63,8 @@ export default class FollowerList extends Component {
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
const paginationControls =
|
const paginationControls =
|
||||||
total > 1 &&
|
pages > 1 &&
|
||||||
Array(total)
|
Array(pages)
|
||||||
.fill()
|
.fill()
|
||||||
.map((x, n) => {
|
.map((x, n) => {
|
||||||
const activePageClass =
|
const activePageClass =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user