summaryrefslogtreecommitdiff
path: root/web/source/settings/lib/form/check-list.jsx
diff options
context:
space:
mode:
authorLibravatar f0x52 <f0x@cthu.lu>2023-02-06 09:19:56 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-06 09:19:56 +0100
commit47daddc10c291ec67320dd2485bffc498ea44bdf (patch)
tree530677541399c27cd292dfc0050a71273c35f098 /web/source/settings/lib/form/check-list.jsx
parent[chore]: Bump codeberg.org/gruf/go-runners from 1.4.0 to 1.5.1 (#1428) (diff)
downloadgotosocial-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/check-list.jsx')
-rw-r--r--web/source/settings/lib/form/check-list.jsx12
1 files changed, 6 insertions, 6 deletions
diff --git a/web/source/settings/lib/form/check-list.jsx b/web/source/settings/lib/form/check-list.jsx
index b19e17a29..7827671be 100644
--- a/web/source/settings/lib/form/check-list.jsx
+++ b/web/source/settings/lib/form/check-list.jsx
@@ -81,13 +81,13 @@ const { reducer, actions } = createSlice({
}
});
-function initialState({ entries, uniqueKey, defaultValue }) {
+function initialState({ entries, uniqueKey, initialValue }) {
const selectedEntries = new Set();
return {
entries: syncpipe(entries, [
(_) => _.map((entry) => {
let key = entry[uniqueKey];
- let checked = entry.checked ?? defaultValue;
+ let checked = entry.checked ?? initialValue;
if (checked) {
selectedEntries.add(key);
@@ -110,9 +110,9 @@ function initialState({ entries, uniqueKey, defaultValue }) {
};
}
-module.exports = function useCheckListInput({ name }, { entries, uniqueKey = "key", defaultValue = false }) {
+module.exports = function useCheckListInput({ name }, { entries, uniqueKey = "key", initialValue = false }) {
const [state, dispatch] = React.useReducer(reducer, null,
- () => initialState({ entries, uniqueKey, defaultValue }) // initial state
+ () => initialState({ entries, uniqueKey, initialValue }) // initial state
);
const toggleAllRef = React.useRef(null);
@@ -132,8 +132,8 @@ module.exports = function useCheckListInput({ name }, { entries, uniqueKey = "ke
}, [state.selectedEntries]);
const reset = React.useCallback(
- () => dispatch(actions.updateAll(defaultValue)),
- [defaultValue]
+ () => dispatch(actions.updateAll(initialValue)),
+ [initialValue]
);
const onChange = React.useCallback(