aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/app/Page/NewCollection.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-06-07 17:08:01 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-06-08 09:56:20 +0200
commit2e67bf911533a66b5a5b7b50481b426adff8c7db (patch)
tree71481ebe7602ea3d5c84438d0ca829e26ca75a2a /frontend/app/Page/NewCollection.hs
parent8a34cc822c2c508472fe29ab2be1b74ba06e59e6 (diff)
reload collections when creating
Diffstat (limited to 'frontend/app/Page/NewCollection.hs')
-rw-r--r--frontend/app/Page/NewCollection.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/frontend/app/Page/NewCollection.hs b/frontend/app/Page/NewCollection.hs
index 282d36e..dbc448b 100644
--- a/frontend/app/Page/NewCollection.hs
+++ b/frontend/app/Page/NewCollection.hs
@@ -10,6 +10,8 @@ where
import Api
import Data.Aeson qualified as A
import Data.Text qualified as T
+import Effect (Eff)
+import Effect qualified as E
import Form qualified as F
import Miso
import Miso.String (toMisoString)
@@ -30,17 +32,20 @@ data Action
| CollectionCreated (Either String ())
deriving (Eq, Show)
-updateModel :: Action -> Model -> Effect Action Model
-updateModel NoOp m = noEff m
-updateModel (FormChanged input) m = noEff m {input}
+updateModel :: Action -> Model -> (Effect Action Model, [Eff])
+updateModel NoOp m = (noEff m, [])
+updateModel (FormChanged input) m = (noEff m {input}, [])
updateModel (FormSubmitted collection) m =
- m <# do
- CollectionCreated <$> createCollection (T.unpack collection)
+ ( m <# do
+ CollectionCreated <$> createCollection (T.unpack collection),
+ []
+ )
updateModel (CollectionCreated (Left err)) m =
- m <# do
- pure NoOp <* consoleLog (toMisoString err)
--- TODO reload collections in main app
-updateModel (CollectionCreated (Right _)) m = noEff m
+ ( m <# do
+ pure NoOp <* consoleLog (toMisoString err),
+ []
+ )
+updateModel (CollectionCreated (Right _)) m = (noEff m, [E.ReloadCollections])
viewModel :: Model -> View Action
viewModel m = do