From d173fcdfa3ad6f6aee721c8553f25f4db38fa302 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:06:19 +0200 Subject: [chore] Convert some settings / admin panel JS to TypeScript (#2247) * initial conversion of STUFF to typescript * more stuff * update babel deps, include commonjs transform * update bundler & eslint configuration * eslint --fix * upgrade deps * update docs, build stuff, peripheral stuff --------- Co-authored-by: f0x --- web/source/settings/lib/query/base.js | 70 ----------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 web/source/settings/lib/query/base.js (limited to 'web/source/settings/lib/query/base.js') diff --git a/web/source/settings/lib/query/base.js b/web/source/settings/lib/query/base.js deleted file mode 100644 index ba02d4e07..000000000 --- a/web/source/settings/lib/query/base.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - GoToSocial - Copyright (C) GoToSocial Authors admin@gotosocial.org - SPDX-License-Identifier: AGPL-3.0-or-later - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -"use strict"; - -const { createApi, fetchBaseQuery } = require("@reduxjs/toolkit/query/react"); -const { serialize: serializeForm } = require("object-to-formdata"); - -function instanceBasedQuery(args, api, extraOptions) { - const state = api.getState(); - const { instance, token } = state.oauth; - - if (args.baseUrl == undefined) { - args.baseUrl = instance; - } - - if (args.discardEmpty) { - if (args.body == undefined || Object.keys(args.body).length == 0) { - return { data: null }; - } - delete args.discardEmpty; - } - - if (args.asForm) { - delete args.asForm; - args.body = serializeForm(args.body, { - indices: true, // Array indices, for profile fields - }); - } - - return fetchBaseQuery({ - baseUrl: args.baseUrl, - prepareHeaders: (headers) => { - if (token != undefined) { - headers.set('Authorization', token); - } - headers.set("Accept", "application/json"); - return headers; - }, - })(args, api, extraOptions); -} - -module.exports = createApi({ - reducerPath: "api", - baseQuery: instanceBasedQuery, - tagTypes: ["Auth", "Emoji", "Reports", "Account", "InstanceRules"], - endpoints: (build) => ({ - instance: build.query({ - query: () => ({ - url: `/api/v1/instance` - }) - }) - }) -}); \ No newline at end of file -- cgit v1.2.3