import { h, Component } from '/js/web_modules/preact.js'; import htm from '/js/web_modules/htm.js'; import { URL_FOLLOWERS } from '/js/utils/constants.js'; const html = htm.bind(h); export default class FollowerList extends Component { constructor(props) { super(props); this.state = { followers: [], followersPage: 0, currentPage: 0, total: 0, }; } componentDidMount() { try { this.getFollowers(); } catch (e) { console.error('followers error: ', e); } } async getFollowers() { const { currentPage } = this.state; const limit = 24; const offset = currentPage * limit; const u = `${URL_FOLLOWERS}?offset=${offset}&limit=${limit}`; const response = await fetch(u); const followers = await response.json(); this.setState({ followers: followers.results, total: response.total, }); } changeFollowersPage(page) { this.setState({ currentPage: page }); this.getFollowers(); } render() { const { followers, total, currentPage } = this.state; if (!followers) { return null; } const noFollowersInfo = html`
Be the first to follow this live stream.
By following this stream you'll get updates when it goes live, receive posts from the streamer, and be featured here as a follower.
Learn more about ${' '} The Fediverse, where you can follow this server as well as so much more.
${displayName}
${displayUsername}