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/form/submit.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/form/submit.js')
-rw-r--r-- | web/source/settings/lib/form/submit.js | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/web/source/settings/lib/form/submit.js b/web/source/settings/lib/form/submit.js index ee30df8a2..2d1d42b3a 100644 --- a/web/source/settings/lib/form/submit.js +++ b/web/source/settings/lib/form/submit.js @@ -21,7 +21,7 @@ const Promise = require("bluebird"); const React = require("react"); -const syncpipe = require("syncpipe"); +const getFormMutations = require("./get-form-mutations"); module.exports = function useFormSubmit(form, mutationQuery, { changedOnly = true, onFinish } = {}) { if (!Array.isArray(mutationQuery)) { @@ -44,25 +44,12 @@ module.exports = function useFormSubmit(form, mutationQuery, { changedOnly = tru } usedAction.current = action; // transform the field definitions into an object with just their values - let updatedFields = []; - const mutationData = syncpipe(form, [ - (_) => Object.values(_), - (_) => _.map((field) => { - if (field.selectedValues != undefined) { - let selected = field.selectedValues(); - if (!changedOnly || selected.length > 0) { - updatedFields.push(field); - return [field.name, selected]; - } - } else if (!changedOnly || field.hasChanged()) { - updatedFields.push(field); - return [field.name, field.value]; - } - return null; - }), - (_) => _.filter((value) => value != null), - (_) => Object.fromEntries(_) - ]); + + const { mutationData, updatedFields } = getFormMutations(form, { changedOnly }); + + if (updatedFields.length == 0) { + return; + } mutationData.action = action; |