From c684a6ea4896db987408c5e8ee8b8754e8c11236 Mon Sep 17 00:00:00 2001 From: Amyas Merivale Date: Fri, 24 Sep 2021 20:14:41 +0200 Subject: [PATCH] Fix enter dashboard state with localStorage. --- marlowe-dashboard-client/src/Dashboard/State.purs | 12 ++++++++---- marlowe-dashboard-client/src/MainFrame/State.purs | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/marlowe-dashboard-client/src/Dashboard/State.purs b/marlowe-dashboard-client/src/Dashboard/State.purs index 902eb4d41c5..3f50e9e9dbd 100644 --- a/marlowe-dashboard-client/src/Dashboard/State.purs +++ b/marlowe-dashboard-client/src/Dashboard/State.purs @@ -62,15 +62,19 @@ import Toast.Types (ajaxErrorToast, decodedAjaxErrorToast, errorToast, successTo -- see note [dummyState] in MainFrame.State dummyState :: State -dummyState = mkInitialState mempty defaultWalletDetails mempty mempty (Slot zero) +dummyState = mkInitialState mempty defaultWalletDetails mempty mempty (Slot zero) MarlowePAB {- [Workflow 2][4] Connect a wallet When we connect a wallet, it has this initial state. Notable is the walletCompanionStatus of `FirstUpdatePending`. Follow the trail of worflow comments to see what happens next. -} -mkInitialState :: WalletLibrary -> WalletDetails -> Map PlutusAppId ContractHistory -> Map PlutusAppId String -> Slot -> State -mkInitialState walletLibrary walletDetails contracts contractNicknames currentSlot = +mkInitialState :: WalletLibrary -> WalletDetails -> Map PlutusAppId ContractHistory -> Map PlutusAppId String -> Slot -> DataProvider -> State +mkInitialState walletLibrary walletDetails contracts contractNicknames currentSlot dataProvider = let + walletCompanionStatus = case dataProvider of + LocalStorage -> FirstUpdateComplete + MarlowePAB -> FirstUpdatePending + mkInitialContractState followerAppId contractHistory = let nickname = fromMaybe mempty $ lookup followerAppId contractNicknames @@ -79,7 +83,7 @@ mkInitialState walletLibrary walletDetails contracts contractNicknames currentSl in { contactsState: Contacts.mkInitialState walletLibrary , walletDetails - , walletCompanionStatus: FirstUpdatePending + , walletCompanionStatus , menuOpen: false , card: Nothing , cardOpen: false diff --git a/marlowe-dashboard-client/src/MainFrame/State.purs b/marlowe-dashboard-client/src/MainFrame/State.purs index 7c5474010d2..f3a776e4ecd 100644 --- a/marlowe-dashboard-client/src/MainFrame/State.purs +++ b/marlowe-dashboard-client/src/MainFrame/State.purs @@ -283,7 +283,8 @@ handleAction (EnterDashboardState walletLibrary walletDetails) = do -- we've just subscribed to this wallet's WalletCompanion app, however, the creation of new -- MarloweFollower apps will be triggered by the initial WebSocket status notification. contractNicknames <- getContractNicknames - assign _subState $ Right $ Dashboard.mkInitialState walletLibrary walletDetails followerApps contractNicknames currentSlot + { dataProvider } <- ask + assign _subState $ Right $ Dashboard.mkInitialState walletLibrary walletDetails followerApps contractNicknames currentSlot dataProvider handleAction (WelcomeAction welcomeAction) = toWelcome $ Welcome.handleAction welcomeAction