aboutsummaryrefslogtreecommitdiff
path: root/client/src/View/Income/Reducer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/View/Income/Reducer.hs')
-rw-r--r--client/src/View/Income/Reducer.hs19
1 files changed, 7 insertions, 12 deletions
diff --git a/client/src/View/Income/Reducer.hs b/client/src/View/Income/Reducer.hs
index 391890f..ea9f664 100644
--- a/client/src/View/Income/Reducer.hs
+++ b/client/src/View/Income/Reducer.hs
@@ -11,7 +11,8 @@ import qualified Reflex.Dom as R
import Common.Model (IncomePage)
-import Loadable (Loadable2 (..))
+import Loadable (Loadable (..))
+import qualified Loadable as Loadable
import qualified Util.Ajax as AjaxUtil
import qualified Util.Either as EitherUtil
@@ -25,7 +26,7 @@ data In t a b c = In
, _in_deleteIncome :: Event t c
}
-reducer :: forall t m a b c. MonadWidget t m => In t a b c -> m (Loadable2 t IncomePage)
+reducer :: forall t m a b c. MonadWidget t m => In t a b c -> m (Dynamic t (Loadable IncomePage))
reducer input = do
postBuild <- R.getPostBuild
@@ -43,19 +44,13 @@ reducer input = do
getResult <- AjaxUtil.get $ fmap pageUrl loadPage
- isLoading <- R.holdDyn
- True
+ R.holdDyn
+ Loading
(R.leftmost
- [ True <$ loadPage
- , False <$ getResult
+ [ Loading <$ loadPage
+ , Loadable.fromEither <$> getResult
])
- incomePage <- R.holdDyn
- Nothing
- (fmap EitherUtil.eitherToMaybe getResult)
-
- return $ Loadable2 isLoading incomePage
-
where
pageUrl p =
"api/incomes?page="