diff options
author | 2023-06-13 12:21:26 +0200 | |
---|---|---|
committer | 2023-06-13 12:21:26 +0200 | |
commit | 8fb5a7e7f8d4201590e709989e8f0627e800c147 (patch) | |
tree | 2fb888f081584f33e198eadfcf218714c3824002 /web/source/settings/lib/query/base.js | |
parent | [docs] Made Advanced its own section (#1883) (diff) | |
download | gotosocial-8fb5a7e7f8d4201590e709989e8f0627e800c147.tar.xz |
[Frontend] Settings for profile fields (#1885)
* get max emoji size from instance settings
* expose (hardcoded) max amount of profile fields in instance api
* basic profile field setting
* fix profile field hook structure for updates
* *twirls mustache* fix ze tests
---------
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
Diffstat (limited to 'web/source/settings/lib/query/base.js')
-rw-r--r-- | web/source/settings/lib/query/base.js | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/web/source/settings/lib/query/base.js b/web/source/settings/lib/query/base.js index f880853d2..653fc449b 100644 --- a/web/source/settings/lib/query/base.js +++ b/web/source/settings/lib/query/base.js @@ -20,23 +20,7 @@ "use strict"; const { createApi, fetchBaseQuery } = require("@reduxjs/toolkit/query/react"); -const { isPlainObject } = require("is-plain-object"); - -function convertToForm(obj) { - const formData = new FormData(); - Object.entries(obj).forEach(([key, val]) => { - if (isPlainObject(val)) { - Object.entries(val).forEach(([key2, val2]) => { - if (val2 != undefined) { - formData.set(`${key}[${key2}]`, val2); - } - }); - } else if (val != undefined) { - formData.set(key, val); - } - }); - return formData; -} +const { serialize: serializeForm } = require("object-to-formdata"); function instanceBasedQuery(args, api, extraOptions) { const state = api.getState(); @@ -55,7 +39,9 @@ function instanceBasedQuery(args, api, extraOptions) { if (args.asForm) { delete args.asForm; - args.body = convertToForm(args.body); + args.body = serializeForm(args.body, { + indices: true, // Array indices, for profile fields + }); } return fetchBaseQuery({ |