Skip to content

Commit

Permalink
Fix enter dashboard state with localStorage.
Browse files Browse the repository at this point in the history
  • Loading branch information
merivale committed Sep 24, 2021
1 parent 60684df commit c684a6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions marlowe-dashboard-client/src/Dashboard/State.purs
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion marlowe-dashboard-client/src/MainFrame/State.purs
Expand Up @@ -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

Expand Down

0 comments on commit c684a6e

Please sign in to comment.