diff options
author | 2024-05-01 15:11:22 +0200 | |
---|---|---|
committer | 2024-05-01 14:11:22 +0100 | |
commit | 725a21b02721f92ed0420ed3f807ee921de77992 (patch) | |
tree | 3940e4b0a7cf3328357ccb86be971126ab2a12b5 /web/source/settings/lib/query/admin/index.ts | |
parent | [bugfix] Tidy up remaining references to workers in cmd (#2889) (diff) | |
download | gotosocial-725a21b02721f92ed0420ed3f807ee921de77992.tar.xz |
[feature] Page through accounts as moderator (#2881)
* [feature] Page through accounts as moderator
* aaaaa
* use COLLATE "C" for Postgres to ensure same ordering as SQLite
* fix typo, test paging up
* don't show moderation / info for our instance acct
Diffstat (limited to 'web/source/settings/lib/query/admin/index.ts')
-rw-r--r-- | web/source/settings/lib/query/admin/index.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/web/source/settings/lib/query/admin/index.ts b/web/source/settings/lib/query/admin/index.ts index cbe66705b..3e7b1a0a0 100644 --- a/web/source/settings/lib/query/admin/index.ts +++ b/web/source/settings/lib/query/admin/index.ts @@ -20,8 +20,9 @@ import { replaceCacheOnMutation, removeFromCacheOnMutation } from "../query-modifiers"; import { gtsApi } from "../gts-api"; import { listToKeyedObject } from "../transforms"; -import { AdminAccount, HandleSignupParams, SearchAccountParams } from "../../types/account"; +import { AdminAccount, HandleSignupParams, SearchAccountParams, SearchAccountResp } from "../../types/account"; import { InstanceRule, MappedRules } from "../../types/rules"; +import parse from "parse-link-header"; const extended = gtsApi.injectEndpoints({ endpoints: (build) => ({ @@ -65,7 +66,7 @@ const extended = gtsApi.injectEndpoints({ ], }), - searchAccounts: build.query<AdminAccount[], SearchAccountParams>({ + searchAccounts: build.query<SearchAccountResp, SearchAccountParams>({ query: (form) => { const params = new(URLSearchParams); Object.entries(form).forEach(([k, v]) => { @@ -83,10 +84,16 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v2/admin/accounts${query}` }; }, + transformResponse: (apiResp: AdminAccount[], meta) => { + const accounts = apiResp; + const linksStr = meta?.response?.headers.get("Link"); + const links = parse(linksStr); + return { accounts, links }; + }, providesTags: (res) => res ? [ - ...res.map(({ id }) => ({ type: 'Account' as const, id })), + ...res.accounts.map(({ id }) => ({ type: 'Account' as const, id })), { type: 'Account', id: 'LIST' }, ] : [{ type: 'Account', id: 'LIST' }], |