Skip to content

Commit 750d5cc

Browse files
author
Andika Demas Riyandi
committed
fixing dropdown routing
1 parent 0fcda8e commit 750d5cc

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src-ui.v3/src/Main.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ app dynFrag = do
380380
ddReports <- el "p" $ do
381381
evQButton <- button "Queue a build"
382382
text " for the index-state "
383-
tmp <- routePkgIdxTs pn (PkgIdxTs 0) (current dynReports) xs ddCfg
383+
uniqReport <- holdUniqDyn dynReports
384+
tmp <- routePkgIdxTs pn (PkgIdxTs 0) uniqReport xs ddCfg
384385
text " shown below"
385386

386387
_ <- putQueue (constDyn $ Right pn) (Right <$> _dropdown_value tmp) (constDyn $ Right (QEntryUpd (-1))) evQButton

src-ui.v3/src/Router.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,20 @@ routeLink False r w = do
175175
routePkgIdxTs :: forall t m. (PostBuild t m, MonadHold t m, MonadFix m, DomBuilder t m, SetRoute t FragRoute m)
176176
=> PkgN
177177
-> PkgIdxTs
178-
-> Behavior t (Set PkgIdxTs)
178+
-> Dynamic t (Set PkgIdxTs)
179179
-> Dynamic t (Map.Map PkgIdxTs Text)
180180
-> DropdownConfig t PkgIdxTs
181181
-> m (Dropdown t PkgIdxTs)
182182
routePkgIdxTs pn k0 setIdx opt ddConf = do
183183
dd <- dropdown k0 opt ddConf
184-
let evDD = attach setIdx (updated $ dd ^. dropdown_value)
185-
setRoute $ (switchPkgRoute . (\tup -> createRoutePackage pn tup)) <$> evDD
184+
let evDD = updated $ ffor2 setIdx (dd ^. dropdown_value) (\sId dVal -> createRoutePackage pn sId dVal)
185+
--defIdx = RoutePackage (pn, Nothing)
186+
setRoute $ switchPkgRoute <$> evDD
186187
pure dd
187188

188-
createRoutePackage :: PkgN -> (Set PkgIdxTs, PkgIdxTs) -> Maybe FragRoute
189-
createRoutePackage pn (_, PkgIdxTs 0) = Just $ RoutePackage (pn, Nothing)
190-
createRoutePackage pn (setIdx, pkgIdx)
189+
createRoutePackage :: PkgN -> Set PkgIdxTs -> PkgIdxTs -> Maybe FragRoute
190+
createRoutePackage pn _ (PkgIdxTs 0) = Nothing
191+
createRoutePackage pn setIdx pkgIdx
191192
| Just maxIdx <- Set.lookupMax setIdx
192193
, True <- maxIdx /= pkgIdx
193194
= Just $ RoutePackage (pn, Just pkgIdx)

0 commit comments

Comments
 (0)