diff --git a/web/source/settings/components/form/inputs.jsx b/web/source/settings/components/form/inputs.jsx index 1081ead75..050577134 100644 --- a/web/source/settings/components/form/inputs.jsx +++ b/web/source/settings/components/form/inputs.jsx @@ -90,12 +90,30 @@ function Checkbox({label, field, ...inputProps}) { ); +} +function Select({label, field, options, ...inputProps}) { + const {onChange, value} = field; + + return ( +
+ +
+ ); } module.exports = { TextInput, TextArea, FileInput, - Checkbox + Checkbox, + Select }; \ No newline at end of file diff --git a/web/source/settings/lib/form/bool.jsx b/web/source/settings/lib/form/bool.jsx index 5553a269b..a25989a08 100644 --- a/web/source/settings/lib/form/bool.jsx +++ b/web/source/settings/lib/form/bool.jsx @@ -23,6 +23,8 @@ const React = require("react"); module.exports = function useBoolInput({name, Name}, {defaultValue=false} = {}) { const [value, setValue] = React.useState(defaultValue); + console.log("bool", name, value, defaultValue); + function onChange(e) { setValue(e.target.checked); } @@ -40,6 +42,7 @@ module.exports = function useBoolInput({name, Name}, {defaultValue=false} = {}) [`set${Name}`]: setValue } ], { + name, onChange, reset, value, diff --git a/web/source/settings/lib/form/combobox.jsx b/web/source/settings/lib/form/combobox.jsx index aeee38fc2..f61bca986 100644 --- a/web/source/settings/lib/form/combobox.jsx +++ b/web/source/settings/lib/form/combobox.jsx @@ -20,7 +20,7 @@ const { useComboboxState } = require("ariakit/combobox"); -module.exports = function useComboBoxInput({name, Name}, {validator, defaultValue} = {}) { +module.exports = function useComboBoxInput({name, Name}, {defaultValue} = {}) { const state = useComboboxState({ defaultValue, gutter: 0, @@ -31,11 +31,16 @@ module.exports = function useComboBoxInput({name, Name}, {validator, defaultValu state.setValue(""); } - return [ + return Object.assign([ state, reset, + name, { [name]: state.value, } - ]; + ], { + name, + value: state.value, + reset + }); }; \ No newline at end of file diff --git a/web/source/settings/lib/form/file.jsx b/web/source/settings/lib/form/file.jsx index 64433c132..e6492198c 100644 --- a/web/source/settings/lib/form/file.jsx +++ b/web/source/settings/lib/form/file.jsx @@ -82,6 +82,7 @@ module.exports = function useFileInput({name, _Name}, { ], { onChange, reset, + name, value: file, previewValue: imageURL, hasChanged: () => file != undefined, diff --git a/web/source/settings/lib/form/submit.js b/web/source/settings/lib/form/submit.js index 8a2a1fad7..ebb3068ce 100644 --- a/web/source/settings/lib/form/submit.js +++ b/web/source/settings/lib/form/submit.js @@ -29,11 +29,11 @@ module.exports = function useFormSubmit(form, [mutationQuery, result]) { // transform the field definitions into an object with just their values let updatedFields = []; const mutationData = syncpipe(form, [ - (_) => Object.entries(_), - (_) => _.map(([key, field]) => { + (_) => Object.values(_), + (_) => _.map((field) => { if (field.hasChanged()) { updatedFields.push(field); - return [key, field.value]; + return [field.name, field.value]; } else { return null; } diff --git a/web/source/settings/lib/form/text.jsx b/web/source/settings/lib/form/text.jsx index 6b3ad14fe..6b3ca5495 100644 --- a/web/source/settings/lib/form/text.jsx +++ b/web/source/settings/lib/form/text.jsx @@ -56,6 +56,7 @@ module.exports = function useTextInput({name, Name}, {validator, defaultValue="" ], { onChange, reset, + name, value: text, ref: textRef, setter: setText, diff --git a/web/source/settings/user/profile.js b/web/source/settings/user/profile.js index f9bab9623..43d7314ad 100644 --- a/web/source/settings/user/profile.js +++ b/web/source/settings/user/profile.js @@ -43,10 +43,16 @@ const MutationButton = require("../components/form/mutation-button"); const Loading = require("../components/loading"); module.exports = function UserProfile() { - const allowCustomCSS = Redux.useSelector(state => state.instances.current.configuration.accounts.allow_custom_css); - // const profile = Redux.useSelector(state => state.user.profile); const {data: profile = {}, isLoading} = query.useVerifyCredentialsQuery(); + if (isLoading) { + return ; + } else { + return ; + } +}; + +function UserProfileForm({profile}) { /* User profile update form keys - bool bot @@ -55,10 +61,6 @@ module.exports = function UserProfile() { - string note - file avatar - file header - - string source[privacy] - - bool source[sensitive] - - string source[language] - - string source[status_format] - bool enable_rss - string custom_css (if enabled) */ @@ -66,21 +68,17 @@ module.exports = function UserProfile() { const form = { avatar: useFileInput("avatar", {withPreview: true, }), header: useFileInput("header", {withPreview: true, }), - display_name: useTextInput("displayName", {defaultValue: profile.display_name}), + displayName: useTextInput("display_name", {defaultValue: profile.display_name}), note: useTextInput("note", {defaultValue: profile.source?.note}), - custom_css: useTextInput("customCSS", {defaultValue: profile.custom_css}), - bot: useBoolInput("isBot", {defaultValue: profile.bot}), - locked: useBoolInput("isLocked", {defaultValue: profile.locked}), - enable_rss: useBoolInput("enableRSS", {defaultValue: profile.enable_rss}), - "source[sensitive]": useBoolInput("isSensitive", {defaultValue: profile.source?.sensitive}), + customCSS: useTextInput("custom_css", {defaultValue: profile.custom_css}), + bot: useBoolInput("bot", {defaultValue: profile.bot}), + locked: useBoolInput("locked", {defaultValue: profile.locked}), + enableRSS: useBoolInput("enable_rss", {defaultValue: profile.enable_rss}), }; + const allowCustomCSS = Redux.useSelector(state => state.instances.current.configuration.accounts.allow_custom_css); const [result, submitForm] = useFormSubmit(form, query.useUpdateCredentialsMutation()); - if (isLoading) { - return ; - } - return (

Profile

@@ -88,7 +86,7 @@ module.exports = function UserProfile() { @@ -110,7 +108,7 @@ module.exports = function UserProfile() { @@ -125,12 +123,12 @@ module.exports = function UserProfile() { label="Manually approve follow requests" /> { !allowCustomCSS ? null :