aboutsummaryrefslogtreecommitdiff
path: root/client/src/View
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/View')
-rw-r--r--client/src/View/Income/Income.hs2
-rw-r--r--client/src/View/Income/Reducer.hs19
-rw-r--r--client/src/View/Payment/Payment.hs4
-rw-r--r--client/src/View/Payment/Reducer.hs19
4 files changed, 17 insertions, 27 deletions
diff --git a/client/src/View/Income/Income.hs b/client/src/View/Income/Income.hs
index fa2585d..e83ba80 100644
--- a/client/src/View/Income/Income.hs
+++ b/client/src/View/Income/Income.hs
@@ -50,7 +50,7 @@ view input = do
editIncome <- eventFromResult $ Table._out_edit . (\(_, b, _) -> b)
deleteIncome <- eventFromResult $ Table._out_delete . (\(_, b, _) -> b)
- result <- Loadable.view2 incomePage $
+ result <- Loadable.viewShowValueWhileLoading incomePage $
\(IncomePage page header incomes count) -> do
header <- Header.view $ Header.In
{ Header._in_users = _in_users input
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="
diff --git a/client/src/View/Payment/Payment.hs b/client/src/View/Payment/Payment.hs
index a97c3df..8d0fee1 100644
--- a/client/src/View/Payment/Payment.hs
+++ b/client/src/View/Payment/Payment.hs
@@ -38,7 +38,7 @@ view input = do
categories <- AjaxUtil.getNow "api/categories"
- R.dyn . R.ffor categories . Loadable.view $ \categories -> do
+ R.dyn . R.ffor categories . Loadable.viewHideValueWhileLoading $ \categories -> do
rec
paymentPage <- Reducer.reducer $ Reducer.In
@@ -69,7 +69,7 @@ view input = do
, HeaderForm._in_categories = categories
}
- result <- Loadable.view2 paymentPage $
+ result <- Loadable.viewShowValueWhileLoading paymentPage $
\(PaymentPage page frequency header payments count) -> do
HeaderInfos.view $ HeaderInfos.In
diff --git a/client/src/View/Payment/Reducer.hs b/client/src/View/Payment/Reducer.hs
index d221ff0..7468097 100644
--- a/client/src/View/Payment/Reducer.hs
+++ b/client/src/View/Payment/Reducer.hs
@@ -13,7 +13,8 @@ import qualified Reflex.Dom as R
import Common.Model (Frequency (..), PaymentPage)
-import Loadable (Loadable2 (..))
+import Loadable (Loadable (..))
+import qualified Loadable as Loadable
import qualified Util.Ajax as AjaxUtil
import qualified Util.Either as EitherUtil
@@ -44,7 +45,7 @@ data Msg
| ResetSearch
deriving Show
-reducer :: forall t m a b c. MonadWidget t m => In t a b c -> m (Loadable2 t PaymentPage)
+reducer :: forall t m a b c. MonadWidget t m => In t a b c -> m (Dynamic t (Loadable PaymentPage))
reducer input = do
postBuild <- R.getPostBuild
@@ -90,19 +91,13 @@ reducer input = do
getResult <- AjaxUtil.get (pageUrl <$> paramsEvent)
- isLoading <- R.holdDyn
- True
+ R.holdDyn
+ Loading
(R.leftmost
- [ True <$ paramsEvent
- , False <$ getResult
+ [ Loading <$ paramsEvent
+ , Loadable.fromEither <$> getResult
])
- paymentPage <- R.holdDyn
- Nothing
- (fmap EitherUtil.eitherToMaybe getResult)
-
- return $ Loadable2 isLoading paymentPage
-
where
pageUrl (Params page search frequency) =
"api/payments?page="