chore(cache): add caching for simpleLinks and modal access
This commit is contained in:
parent
9fd80f2552
commit
64b21d6fe6
@ -38,7 +38,8 @@ visibleUTCTime dtf t = do
|
||||
-- | Simple link to a known route
|
||||
simpleLink :: HasRoute UniWorX url => Widget -> url -> Widget
|
||||
simpleLink lbl url = do
|
||||
isAuth <- hasReadAccessTo $ urlRoute url
|
||||
let route = urlRoute url
|
||||
isAuth <- liftHandler . $cachedHereBinary route $ hasReadAccessTo route
|
||||
if | isAuth -> do
|
||||
tUrl <- toTextUrl url
|
||||
[whamlet|
|
||||
@ -127,7 +128,7 @@ editedByW fmt tm usr = do
|
||||
-- | like `modal`, but only conditionally displays the modal link only after checking access rights. WARNING: this might be too slow for large dbTable. Use `modalAccessCheckOnClick` instead
|
||||
modalAccess :: Widget -> Widget -> Bool -> Route UniWorX -> Widget
|
||||
modalAccess wdgtNo wdgtYes writeAccess route = do
|
||||
authOk <- liftHandler $ bool hasReadAccessTo hasWriteAccessTo writeAccess route
|
||||
authOk <- liftHandler . $cachedHereBinary (route, writeAccess) $ bool hasReadAccessTo hasWriteAccessTo writeAccess route
|
||||
if authOk
|
||||
then modal wdgtYes (Left $ SomeRoute route)
|
||||
else wdgtNo
|
||||
|
||||
Loading…
Reference in New Issue
Block a user