aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/app/Page
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-12-18 19:11:03 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2025-02-19 18:44:43 +0100
commit9b0adc976101bc4f375b05cc475478187c595714 (patch)
tree67dde004c05d5bcf380c72f0134ac673f6a4f027 /frontend/app/Page
parent04a9bbfab5536791f4850903ebb339c846341184 (diff)
add pagination to rest api
Diffstat (limited to 'frontend/app/Page')
-rw-r--r--frontend/app/Page/ListCollection.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/frontend/app/Page/ListCollection.hs b/frontend/app/Page/ListCollection.hs
index ff659af..9e3caaa 100644
--- a/frontend/app/Page/ListCollection.hs
+++ b/frontend/app/Page/ListCollection.hs
@@ -8,26 +8,28 @@ module Page.ListCollection
where
import ACMS.API.REST.Collection qualified as API.REST.Collection
+import ACMS.API.REST.Collection.Paginated (Paginated (..))
+import ACMS.API.REST.Collection.Paginated qualified as API.REST.Collection.Paginated
+import Collection
import Control.Monad.Catch (SomeException, try)
import Data.Aeson qualified as A
import Data.Aeson.KeyMap qualified as AM
import Effect (Eff)
import Miso
import Schema
-import Collection
data Model = Model
{ collection :: Collection,
input :: A.Object,
schema :: Schema,
- posts :: [A.Object]
+ posts :: Paginated A.Object
}
deriving (Show, Eq)
initialModel :: Collection -> JSM (Either SomeException Model)
initialModel collection = do
schema' <- try (API.REST.Collection.schema collection)
- posts' <- try (API.REST.Collection.list collection)
+ posts' <- try (API.REST.Collection.Paginated.list (API.REST.Collection.Paginated.Pagination 10 0) collection)
pure do
schema <- schema'
posts <- posts'