@@ -7,7 +7,7 @@ import BW (ApiService, CryptoFunctions, Services, CryptoService)
77import BW as WB
88import BW.Logic (decodeCipher, decrypt, encodeCipher, hashPassword, liftPromise)
99import BW.Logic as Logic
10−import BW.Types (CipherResponse, Email(..), Password(..), Urls, cipherTypeCard, cipherTypeIdentity, cipherTypeLogin, cipherTypeSecureNote)
10+import BW.Types (CipherResponse, Email(..), Password(..), Urls, SyncResponse, cipherTypeCard, cipherTypeIdentity, cipherTypeLogin, cipherTypeSecureNote)
1111import Bridge as Bridge
1212import Control.Monad.Error.Class (catchError, throwError)
1313import Data.Argonaut (class DecodeJson)
@@ -140,7 +140,10 @@ main = do
140140 Storage.store storage SyncKey sync
141141 Storage.store storage TokenKey token
142142 send Bridge.LoginSuccessful
143− Bridge.NeedCiphersList -> runWithDecryptionKey performSync
143+ Bridge.NeedCiphersList ->
144+ runWithDecryptionKey do
145+ sendCiphers
146+ performSync
144147 Bridge.NeedsReset -> do
145148 WebStorage.clear storage
146149 Elm.send app Bridge.Reset
@@ -345,7 +348,25 @@ performSync = do
345348 storage <- askAt (Proxy :: _ "storage")
346349 newSync <- liftPromise $ api.getSync unit
347350 liftEffect $ Storage.store storage SyncKey newSync
348− ciphers <- traverse processCipher newSync.ciphers
351+ sendCiphers
352+
353+sendCiphers ::
354+ forall r.
355+ Run
356+ ( storage :: Reader Storage
357+ , app :: Reader Elm
358+ , aff :: Aff
359+ , effect :: Effect
360+ , services :: Reader Services
361+ , crypto :: Reader CryptoService
362+ , key :: Reader SymmetricCryptoKey
363+ | r
364+ )
365+ Unit
366+sendCiphers = do
367+ sync <- getOrReset SyncKey
368+ ciphers <- traverse processCipher sync.ciphers
349369 let
350370 sortedCiphers = Array.sortWith (_.date >>> Down) ciphers
351371 send $ Bridge.LoadCiphers $ Bridge.Sub_LoadCiphers_List $ map _.cipher sortedCiphers
372+ pure unit