@@ -16,6 +16,7 @@ import useTranslationFunction from '../../hooks/useTranslationFunction'
1616import useDialog from '../../hooks/dialog/useDialog'
1717import { DialogId } from '../../contexts/DialogContext'
1818import AlertDialog from '../dialogs/AlertDialog'
19+ import SettingsStoreInstance , { useSettingsStore } from '../../stores/settings'
1920
2021import type ScreenController from '../../ScreenController'
2122
@@ -32,25 +33,43 @@ export default function AccountSetupScreen({
3233
3334 const [ credentials , setCredentials ] =
3435 useState < Credentials > ( defaultCredentials ( ) )
35-
36- const onClickLogin = useCallback (
37- ( ) =>
38- openDialog ( ConfigureProgressDialog , {
39- credentials,
40- onSuccess : ( ) => {
41- selectAccount ( accountId )
42- } ,
43- onFail : ( error : string ) =>
44- setPromptDialogId (
45- openDialog ( AlertDialog , {
46- message : error ,
47- cb : ( ) => setPromptDialogId ( null ) ,
48- } )
49- ) ,
50- } ) ,
51- [ accountId , openDialog , selectAccount , credentials ]
36+ const settingsStore = useSettingsStore ( ) [ 0 ]
37+ const [ forceEncryption , setForceEncryption ] = useState < boolean > (
38+ settingsStore ?. settings [ 'force_encryption' ] === '1'
5239 )
5340
41+ const onClickLogin = useCallback ( ( ) => {
42+ openDialog ( ConfigureProgressDialog , {
43+ credentials,
44+ onSuccess : async ( ) => {
45+ const forceEncryptionValue = forceEncryption ? '1' : '0'
46+ if (
47+ settingsStore ?. settings [ 'force_encryption' ] !== forceEncryptionValue
48+ ) {
49+ await SettingsStoreInstance . effect . setCoreSetting (
50+ 'force_encryption' ,
51+ forceEncryptionValue
52+ )
53+ }
54+ selectAccount ( accountId )
55+ } ,
56+ onFail : ( error : string ) =>
57+ setPromptDialogId (
58+ openDialog ( AlertDialog , {
59+ message : error ,
60+ cb : ( ) => setPromptDialogId ( null ) ,
61+ } )
62+ ) ,
63+ } )
64+ } , [
65+ accountId ,
66+ credentials ,
67+ forceEncryption ,
68+ openDialog ,
69+ selectAccount ,
70+ settingsStore ,
71+ ] )
72+
5473 // TODO(maxph): we're now using <dialog> and can submit result via input
5574 // and not an explicit keyboard handling
5675 const onKeyDown = useCallback (
@@ -88,6 +107,8 @@ export default function AccountSetupScreen({
88107 < LoginForm
89108 credentials = { credentials }
90109 setCredentials = { setCredentials }
110+ forceEncryption = { forceEncryption }
111+ setForceEncryption = { setForceEncryption }
91112 />
92113 </ DialogContent >
93114 </ DialogBody >
0 commit comments