diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2025-08-31 10:38:04 +0200 | 
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-08-31 22:18:45 +0200 | 
| commit | 5cc8be366056baa29048acc11f4b5e14d5dbd652 (patch) | |
| tree | f5a688907dbee33c9faf152a7b4a1d1652df90b4 /src | |
| parent | b2efb9e969ef992612e81afa26d65478c060233c (diff) | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/Main.hs | 34 | 
1 files changed, 17 insertions, 17 deletions
| diff --git a/src/Main.hs b/src/Main.hs index 9c8d552..644b2d3 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -60,13 +60,14 @@ data CurrentConversation  initGlobalState :: IO GlobalState  initGlobalState = do      globalStorage <- memoryStorage -    identity <- createIdentity globalStorage Nothing Nothing -    globalHead <- storeHead globalStorage $ LocalState -        { lsPrev = Nothing, lsIdentity = idExtData identity, lsShared = [], lsOther = [] } -    peerListVar <- newMVar [] -    currentConversationVar <- newMVar NoCurrentConversation -    conversationsVar <- newMVar [] -    return GlobalState {..} +    (either (fail . showErebosError) return =<<) $ runExceptT $ flip runReaderT globalStorage $ do +        identity <- createIdentity Nothing Nothing +        globalHead <- storeHead globalStorage $ LocalState +            { lsPrev = Nothing, lsIdentity = idExtData identity, lsShared = [], lsOther = [] } +        peerListVar <- liftIO $ newMVar [] +        currentConversationVar <- liftIO $ newMVar NoCurrentConversation +        conversationsVar <- liftIO $ newMVar [] +        return GlobalState {..}  foreign export javascript setup :: IO ()  setup :: IO () @@ -112,16 +113,15 @@ setup = do      watchConversations gs      let devName = T.pack "WebApp" -    let st = globalStorage -    owner <- createIdentity st Nothing Nothing -    identity <- createIdentity st (Just devName) (Just owner) - -    shared <- wrappedStore st $ SharedState -        { ssPrev = [] -        , ssType = Just $ sharedTypeID @(Maybe ComposedIdentity) Proxy -        , ssValue = [ storedRef $ idExtData owner ] -        } -    flip runReaderT globalHead $ do +    (either (fail . showErebosError) return =<<) $ runExceptT $ flip runReaderT globalHead $ do +        owner <- createIdentity Nothing Nothing +        identity <- createIdentity (Just devName) (Just owner) + +        shared <- mstore SharedState +            { ssPrev = [] +            , ssType = Just $ sharedTypeID @(Maybe ComposedIdentity) Proxy +            , ssValue = [ storedRef $ idExtData owner ] +            }          updateLocalState_ $ \_ -> do              mstore $ LocalState                  { lsPrev = Nothing |