aboutsummaryrefslogtreecommitdiff
path: root/client/src/View
diff options
context:
space:
mode:
authorJoris2019-08-10 09:59:22 +0200
committerJoris2019-08-10 09:59:22 +0200
commit3943c50d5320f7137bd5acec4485dd56a2aa52b3 (patch)
tree6d2e1f344b326303b8e37d8aa6bac3f5e5ec1ee3 /client/src/View
parent7c77e52faa71e43324087903c905f9d493b1dfb7 (diff)
Debounce payments search
Diffstat (limited to 'client/src/View')
-rw-r--r--client/src/View/Payment.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/client/src/View/Payment.hs b/client/src/View/Payment.hs
index ae20079..915cc18 100644
--- a/client/src/View/Payment.hs
+++ b/client/src/View/Payment.hs
@@ -6,6 +6,7 @@ module View.Payment
import Data.Text (Text)
import qualified Data.Text as T
+import Data.Time.Clock (NominalDiffTime)
import Prelude hiding (init)
import Reflex.Dom (Dynamic, Event, MonadWidget, Reflex)
import qualified Reflex.Dom as R
@@ -47,10 +48,16 @@ widget paymentIn = do
let searchPayments =
getSearchPayments
- (_headerOut_searchName header)
+ debouncedSearchName
(_headerOut_searchFrequency header)
payments
+ debouncedSearchNameEvt <-
+ R.debounce (0.5 :: NominalDiffTime) (R.updated $ _headerOut_searchName header)
+
+ debouncedSearchName <-
+ R.holdDyn "" debouncedSearchNameEvt
+
header <- Header.widget $ HeaderIn
{ _headerIn_init = init
, _headerIn_payments = payments
@@ -70,8 +77,8 @@ widget paymentIn = do
{ _pagesIn_total = length <$> searchPayments
, _pagesIn_perPage = paymentsPerPage
, _pagesIn_reset = R.leftmost $
- [ fmap (const ()) . R.updated . _headerOut_searchName $ header
- , fmap (const ()) . _headerOut_addPayment $ header
+ [ const () <$> debouncedSearchNameEvt
+ , const () <$> _headerOut_addPayment header
]
}