@@ -20,7 +20,6 @@ import Data.Either (Either(..))
2020import Data.HCaptcha (bindHCaptchToken)
2121import Data.JNullable (jnull, nullify)
2222import Data.Maybe (Maybe(..))
23−import Data.Newtype (wrap)
2423import Data.OpenURL (openURL)
2524import Data.Ord.Down (Down(..))
2625import Data.SymmetricCryptoKey (SymmetricCryptoKey)
@@ -86,6 +85,7 @@ main = do
8685 , crypto: services.crypto
8786 , storage
8887 , cryptoFunctions: services.cryptoFunctions
88+ , app
8989 }
9090 flip runReaderT env do
9191 prelogin <- liftPromise $ unauthedApi.postPrelogin { email }
@@ -94,9 +94,7 @@ main = do
9494 (Logic.getLogInRequestToken prelogin (Email email) (Password password) captchaToken)
9595 (const $ liftEffect $ Exc.throw "Could not log in. Please check your data and try again.")
9696 case toEither1 loginResponse of
97− Left { siteKey } ->
98− liftEffect do
99− Elm.send app $ Bridge.NeedsCaptcha siteKey
97+ Left { siteKey } -> send $ Bridge.NeedsCaptcha siteKey
10098 Right token -> do
10199 masterKey <- Logic.makePreloginKey prelogin (Email email) (Password password)
102100 api <- liftPromise $ services.getApi urls (nullify token)
@@ -110,16 +108,15 @@ main = do
110108 Storage.store storage PreloginResponseKey prelogin
111109 Storage.store storage SyncKey sync
112110 Storage.store storage TokenKey token
113− Elm.send app Bridge.LoginSuccessful
111+ send Bridge.LoginSuccessful
114112 Bridge.NeedCiphersList ->
115113 run do
116114 sync <- getOrReset SyncKey
117115 ciphers <- traverse processCipher sync.ciphers
118116 let
119117 sortedCiphers = Array.sortWith (_.date >>> Down) ciphers
120− liftEffect do
121− Elm.send app $ Bridge.LoadCiphers $ Bridge.Sub_LoadCiphers_List $ map _.cipher sortedCiphers
122− Storage.store storage SyncKey sync
118+ send $ Bridge.LoadCiphers $ Bridge.Sub_LoadCiphers_List $ map _.cipher sortedCiphers
119+ liftEffect $ Storage.store storage SyncKey sync
123120 Bridge.NeedsReset -> do
124121 WebStorage.clear storage
125122 Elm.send app Bridge.Reset
@@ -134,11 +131,10 @@ main = do
134131 sync <- getOrReset SyncKey
135132 prelogin <- getOrReset PreloginResponseKey
136133 masterKey <- Logic.makePreloginKey prelogin (Email sync.profile.email) (Password masterPassword)
137− liftEffect do
138− Ref.write (Just masterKey) masterKeyRef
139− Elm.send app Bridge.LoginSuccessful
134+ liftEffect $ Ref.write (Just masterKey) masterKeyRef
135+ send Bridge.LoginSuccessful
140136 else do
141− liftEffect $ Elm.send app $ Bridge.Error "The password is wrong. Please try again."
137+ send $ Bridge.Error "The password is wrong. Please try again."
142138 requestMasterPassword
143139 Bridge.Init -> do
144140 liftEffect $ Storage.get storage TokenKey
@@ -254,11 +250,9 @@ getAuthedApi = do
254250
255251requestMasterPassword :: forall r. HasL "storage" Storage r => HasL "app" Elm r => Al r Unit
256252requestMasterPassword = do
257− app <- l (L :: L "app")
258253 url <- getOrReset UrlsKey
259254 sync <- getOrReset SyncKey
260− liftEffect $ Elm.send app $ Bridge.NeedsMasterPassword
261− $ Bridge.Sub_NeedsMasterPassword { server: url, login: sync.profile.email }
255+ send $ Bridge.NeedsMasterPassword $ Bridge.Sub_NeedsMasterPassword { server: url, login: sync.profile.email }
262256
263257send :: forall r. HasL "app" Elm r => Bridge.Sub -> Al r Unit
264258send sub = do