Less modifyState identity

parent 6a64b6e0
...@@ -186,11 +186,11 @@ performAction (ChangePageSize ps) _ _ = void (cotransform (\state -> changePage ...@@ -186,11 +186,11 @@ performAction (ChangePageSize ps) _ _ = void (cotransform (\state -> changePage
performAction (ChangePage p) _ _ = void (cotransform (\(TableData td) -> TableData $ td { currentPage = p} )) performAction (ChangePage p) _ _ = void (cotransform (\(TableData td) -> TableData $ td { currentPage = p} ))
performAction LoadData _ _ = void do performAction LoadData _ _ = do
res <- lift $ loadPage res <- lift $ loadPage
case res of case res of
Left err -> cotransform $ \state -> state Left err -> pure unit
Right resData -> modifyState (\s -> resData) Right resData -> void $ modifyState (\s -> resData)
loadPage :: Aff (Either String CorpusTableData) loadPage :: Aff (Either String CorpusTableData)
......
...@@ -18,13 +18,11 @@ getUser id = get $ "http://localhost:8008/node/" <> show id ...@@ -18,13 +18,11 @@ getUser id = get $ "http://localhost:8008/node/" <> show id
performAction :: PerformAction State {} Action performAction :: PerformAction State {} Action
performAction (FetchUser userId) _ _ = void do performAction (FetchUser userId) _ _ = do
value <- lift $ getUser userId value <- lift $ getUser userId
_ <- case value of _ <- case value of
(Right user) -> modifyState \state -> set _user (Just user) state (Right user) -> void $ modifyState \state -> set _user (Just user) state
(Left err) -> do (Left err) -> do
_ <- liftEffect $ log err liftEffect $ log err
modifyState identity
liftEffect <<< log $ "Fetching user..." liftEffect <<< log $ "Fetching user..."
performAction _ _ _ = void do performAction _ _ _ = pure unit
modifyState identity
...@@ -67,14 +67,14 @@ performAction Initialize _ state = void do ...@@ -67,14 +67,14 @@ performAction Initialize _ state = void do
case lnodes of case lnodes of
Left err -> do Left err -> do
modifyState identity pure unit
Right d -> do Right d -> do
_ <- modifyState $ _ { initialized = true, ntreeState = d} _ <- modifyState $ _ { initialized = true, ntreeState = d}
page <- lift $ DV.loadPage page <- lift $ DV.loadPage
case page of case page of
Left err -> do Left err -> do
modifyState identity pure unit
Right docs -> do Right docs -> void do
modifyState $ _ { initialized = true modifyState $ _ { initialized = true
, ntreeState = d , ntreeState = d
-- if length d > 0 -- if length d > 0
...@@ -85,7 +85,7 @@ performAction Initialize _ state = void do ...@@ -85,7 +85,7 @@ performAction Initialize _ state = void do
, docViewState = docs , docViewState = docs
} }
_ -> do _ -> do
modifyState identity pure unit
performAction (LoginA _) _ _ = pure unit performAction (LoginA _) _ _ = pure unit
performAction (AddCorpusA _) _ _ = pure unit performAction (AddCorpusA _) _ _ = pure unit
......
...@@ -33,17 +33,17 @@ performAction (SelectDatabase selected) _ _ = void do ...@@ -33,17 +33,17 @@ performAction (SelectDatabase selected) _ _ = void do
performAction (UnselectDatabase unselected) _ _ = void do performAction (UnselectDatabase unselected) _ _ = void do
modifyState \( state) -> state { unselect_database = unselected } modifyState \( state) -> state { unselect_database = unselected }
performAction (LoadDatabaseDetails) _ _ = void do performAction (LoadDatabaseDetails) _ _ = do
res <- lift $ getDatabaseDetails $ QueryString { query_query: "string",query_name: ["Pubmed"]} res <- lift $ getDatabaseDetails $ QueryString { query_query: "string",query_name: ["Pubmed"]}
case res of case res of
Left err -> modifyState $ \(state) -> state Left err -> pure unit
Right resData -> do Right resData -> do
modifyState $ \(state) -> state {response = resData} void $ modifyState $ \(state) -> state {response = resData}
performAction GO _ _ = void do performAction GO _ _ = do
_ <- liftEffect $ setHash "/corpus" liftEffect $ setHash "/corpus"
_ <- liftEffect $ modalHide "addCorpus" liftEffect $ modalHide "addCorpus"
modifyState identity pure unit
newtype QueryString = QueryString newtype QueryString = QueryString
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment