diff options
author | 2023-02-06 09:19:56 +0100 | |
---|---|---|
committer | 2023-02-06 09:19:56 +0100 | |
commit | 47daddc10c291ec67320dd2485bffc498ea44bdf (patch) | |
tree | 530677541399c27cd292dfc0050a71273c35f098 /web/source/settings/lib/form/submit.js | |
parent | [chore]: Bump codeberg.org/gruf/go-runners from 1.4.0 to 1.5.1 (#1428) (diff) | |
download | gotosocial-47daddc10c291ec67320dd2485bffc498ea44bdf.tar.xz |
[chore/frogend] Restructure form data default values / update from Query data (#1422)
* eslint: set console use to error to catch debug littering in CI
* remove debug logging
* some form field restructuring, fixes submitted updates not being reflected
* more form field restructuring
* remove debug logger
* simplify field updates
* fix react state set during render when submitting import file
* className instead of class
* show Select hints again
Diffstat (limited to 'web/source/settings/lib/form/submit.js')
-rw-r--r-- | web/source/settings/lib/form/submit.js | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/web/source/settings/lib/form/submit.js b/web/source/settings/lib/form/submit.js index 6f20165a5..2a81307c5 100644 --- a/web/source/settings/lib/form/submit.js +++ b/web/source/settings/lib/form/submit.js @@ -18,7 +18,6 @@ "use strict"; -const Promise = require("bluebird"); const React = require("react"); const syncpipe = require("syncpipe"); @@ -27,7 +26,7 @@ module.exports = function useFormSubmit(form, mutationQuery, { changedOnly = tru throw new ("useFormSubmit: mutationQuery was not an Array. Is a valid useMutation RTK Query provided?"); } const [runMutation, result] = mutationQuery; - const [usedAction, setUsedAction] = React.useState(); + const usedAction = React.useRef(null); return [ function submitForm(e) { let action; @@ -41,7 +40,7 @@ module.exports = function useFormSubmit(form, mutationQuery, { changedOnly = tru if (action == "") { action = undefined; } - setUsedAction(action); + usedAction.current = action; // transform the field definitions into an object with just their values let updatedFields = []; const mutationData = syncpipe(form, [ @@ -65,19 +64,11 @@ module.exports = function useFormSubmit(form, mutationQuery, { changedOnly = tru mutationData.action = action; - return Promise.try(() => { - return runMutation(mutationData); - }).then((res) => { - if (res.error == undefined) { - updatedFields.forEach((field) => { - field.reset(); - }); - } - }); + return runMutation(mutationData); }, { ...result, - action: usedAction + action: usedAction.current } ]; };
\ No newline at end of file |