Skip to content

Commit

Permalink
Reset the values after loading is finished
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed May 2, 2024
1 parent bc2cd45 commit db04da1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions web/src/components/storage/EncryptionSettingsDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,19 @@ export default function EncryptionSettingsDialog({
const [method, setMethod] = useState(methodProp);
const [passwordsMatch, setPasswordsMatch] = useState(true);
const [validSettings, setValidSettings] = useState(true);
const [wasLoading, setWasLoading] = useState(isLoading);
const formId = "encryptionSettingsForm";

// refresh the state when the real values are loaded
if (method === "" && methodProp !== "") { setMethod(methodProp) }
if (password === "" && passwordProp !== "") {
setPassword(passwordProp);
setIsEnabled(true);
// reset the settings only after loading is finished
if (isLoading && !wasLoading) { setWasLoading(true) }
if (!isLoading && wasLoading) {
setWasLoading(false);
// refresh the state when the real values are loaded
if (method !== methodProp) { setMethod(methodProp) }
if (password !== passwordProp) {
setPassword(passwordProp);
setIsEnabled(passwordProp?.length > 0);
}
}

useEffect(() => {
Expand Down

0 comments on commit db04da1

Please sign in to comment.