reload collections when creating
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user