Skip to content

Commit

Permalink
feat: change members list view to paginate members
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Feb 21, 2025
1 parent 03b4805 commit 6a1c7fe
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions examples/gno.land/r/nt/boards2/v1/render.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"gno.land/p/demo/mux"
"gno.land/p/jeronimoalbi/pager"
)

const (
Expand Down Expand Up @@ -145,13 +146,20 @@ func renderMembers(res *mux.ResponseWriter, req *mux.Request) {
res.Write("# Boards Members\n\n")
}

// TODO: Add pagination support
start := 0
count := 50
perms.IterateUsers(start, count, func(u User) bool {
p, err := pager.New(req.RawPath, perms.UsersCount())
if err != nil {
res.Write(err.Error())
return
}

perms.IterateUsers(p.Offset(), p.PageSize(), func(u User) bool {
res.Write("- " + u.Address.String() + " " + rolesToString(u.Roles) + "\n")
return false
})

if p.HasPages() {
res.Write("\n\n" + pager.Picker(p))
}
}

func rolesToString(roles []Role) string {
Expand Down

0 comments on commit 6a1c7fe

Please sign in to comment.