mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 22:33:06 +03:00
link-view: in pagination logic, only +lent once
Also just use +swag instead of chaining +scag and +slag manually.
This commit is contained in:
parent
8f3d174c94
commit
4da0d636d3
@ -161,15 +161,16 @@
|
|||||||
::
|
::
|
||||||
++ page-size 25
|
++ page-size 25
|
||||||
++ get-paginated
|
++ get-paginated
|
||||||
|* [p=(unit @ud) l=(list)]
|
|* [page=(unit @ud) list=(list)]
|
||||||
^- [total=@ud pages=@ud page=_l]
|
^- [total=@ud pages=@ud page=_list]
|
||||||
:+ (lent l)
|
=/ l=@ud (lent list)
|
||||||
%+ add (div (lent l) page-size)
|
:+ l
|
||||||
(min 1 (mod (lent l) page-size))
|
%+ add (div l page-size)
|
||||||
?~ p l
|
(min 1 (mod l page-size))
|
||||||
%+ scag page-size
|
?~ page list
|
||||||
%+ slag (mul u.p page-size)
|
%+ swag
|
||||||
l
|
[(mul u.page page-size) page-size]
|
||||||
|
list
|
||||||
::
|
::
|
||||||
++ page-to-json
|
++ page-to-json
|
||||||
=, enjs:format
|
=, enjs:format
|
||||||
|
Loading…
Reference in New Issue
Block a user