Fix the listing of follower tables in admin

This commit is contained in:
Gabe Kangas
2023-03-22 14:54:34 -07:00
parent 78fe01d049
commit bb14af399e

View File

@@ -33,6 +33,25 @@ export interface Follower {
approved: Date; approved: Date;
} }
const FollowersTable = ({ data, tableColumns, totalCount, setCurrentPage }) => (
<Table
dataSource={data}
columns={tableColumns}
size="small"
rowKey={row => row.link}
pagination={{
pageSize: 25,
hideOnSinglePage: true,
showSizeChanger: false,
total: totalCount,
}}
onChange={pagination => {
const page = pagination.current;
setCurrentPage(page);
}}
/>
);
export default function FediverseFollowers() { export default function FediverseFollowers() {
const [followersPending, setFollowersPending] = useState<Follower[]>([]); const [followersPending, setFollowersPending] = useState<Follower[]>([]);
const [followersBlocked, setFollowersBlocked] = useState<Follower[]>([]); const [followersBlocked, setFollowersBlocked] = useState<Follower[]>([]);
@@ -47,7 +66,7 @@ export default function FediverseFollowers() {
const getFollowers = async () => { const getFollowers = async () => {
try { try {
const limit = 50; const limit = 25;
const offset = currentPage * limit; const offset = currentPage * limit;
const u = `${FOLLOWERS}?offset=${offset}&limit=${limit}`; const u = `${FOLLOWERS}?offset=${offset}&limit=${limit}`;
@@ -116,27 +135,6 @@ export default function FediverseFollowers() {
}, },
]; ];
function makeTable(data: Follower[], tableColumns: ColumnsType<Follower>) {
return (
<Table
dataSource={data}
columns={tableColumns}
size="small"
rowKey={row => row.link}
pagination={{
pageSize: 50,
hideOnSinglePage: true,
showSizeChanger: false,
total: totalCount,
}}
onChange={pagination => {
const page = pagination.current;
setCurrentPage(page);
}}
/>
);
}
async function approveFollowRequest(request) { async function approveFollowRequest(request) {
try { try {
await fetchData(SET_FOLLOWER_APPROVAL, { await fetchData(SET_FOLLOWER_APPROVAL, {
@@ -307,7 +305,12 @@ export default function FediverseFollowers() {
const followersTab = ( const followersTab = (
<> <>
<p>The following accounts get notified when you go live or send a post.</p> <p>The following accounts get notified when you go live or send a post.</p>
{makeTable(followers, followersColumns)}{' '} <FollowersTable
data={followers}
tableColumns={followersColumns}
totalCount={totalCount}
setCurrentPage={setCurrentPage}
/>
</> </>
); );
@@ -323,7 +326,12 @@ export default function FediverseFollowers() {
</a>{' '} </a>{' '}
and be alerted to when you go live. Each must be approved. and be alerted to when you go live. Each must be approved.
</p> </p>
{makeTable(followersPending, pendingColumns)} <Table
dataSource={followersPending}
columns={pendingColumns}
size="small"
rowKey={row => row.link}
/>
</> </>
); );
@@ -336,7 +344,14 @@ export default function FediverseFollowers() {
The following people were either rejected or blocked by you. You can approve them as a The following people were either rejected or blocked by you. You can approve them as a
follower. follower.
</p> </p>
<p>{makeTable(followersBlocked, blockedColumns)}</p> <p>
<Table
dataSource={followersBlocked}
columns={blockedColumns}
size="small"
rowKey={row => row.link}
/>
</p>
</> </>
); );