-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(boards2): pagination #3586
base: devx/feature/boardsv2
Are you sure you want to change the base?
feat(boards2): pagination #3586
Conversation
🛠 PR Checks Summary🔴 Maintainers must be able to edit this pull request (more info) Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🔴 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
func mustGetPagination(req *mux.Request, pageSize int) *PaginationOpts { | ||
p := pager.Pager{ | ||
PageQueryParam: "page", | ||
DefaultPageSize: pageSize, | ||
} | ||
|
||
pageNumber, _, err := p.ParseQuery(req.RawPath) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return &PaginationOpts{ | ||
Pager: p, | ||
PageNumber: pageNumber, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func mustGetPagination(req *mux.Request, pageSize int) *PaginationOpts { | |
p := pager.Pager{ | |
PageQueryParam: "page", | |
DefaultPageSize: pageSize, | |
} | |
pageNumber, _, err := p.ParseQuery(req.RawPath) | |
if err != nil { | |
panic(err) | |
} | |
return &PaginationOpts{ | |
Pager: p, | |
PageNumber: pageNumber, | |
} | |
} | |
func mustGetPagination(rawPath string, pageSize int) *PaginationOpts { | |
p := pager.Pager{ | |
PageQueryParam: "page", | |
DefaultPageSize: pageSize, | |
} | |
pageNumber, _, err := p.ParseQuery(rawPath) | |
if err != nil { | |
panic(err) | |
} | |
return &PaginationOpts{ | |
Pager: p, | |
PageNumber: pageNumber, | |
} | |
} |
res.Write("These are all the boards of this realm:\n\n") | ||
gBoardsByID.Iterate("", "", func(_ string, value interface{}) bool { | ||
p := mustGetPagination(req, boardsPageSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p := mustGetPagination(req, boardsPageSize) | |
p := mustGetPagination(req.RawPath, boardsPageSize) |
} | ||
|
||
board := v.(*Board) | ||
p := mustGetPagination(req, threadsPageSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p := mustGetPagination(req, threadsPageSize) | |
p := mustGetPagination(req.RawPath, threadsPageSize) |
@@ -63,7 +77,8 @@ func renderThread(res *mux.ResponseWriter, req *mux.Request) { | |||
} else if thread.IsHidden() { | |||
res.Write("Thread with ID: " + rawID + " has been flagged as inappropriate") | |||
} else { | |||
res.Write(thread.Render("", 5)) | |||
p := mustGetPagination(req, repliesPageSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p := mustGetPagination(req, repliesPageSize) | |
p := mustGetPagination(req.RawPath, repliesPageSize) |
Pager pager.Pager | ||
PageNumber int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should Pager
and PageNumber
be public? What do you think about making them private?
Also PageNumber
could be removed I think, because is available as Pager.PageNumber
.
// Render renders a board into Markdown. | ||
// | ||
// Pager is used for pagination if it's not nil. | ||
func (board *Board) Render(p *PaginationOpts) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, it might be possible to use a struct instead of a pointer everywhere when using PaginationOpts
as argument:
func (board *Board) Render(p *PaginationOpts) string { | |
func (board *Board) Render(p PaginationOpts) string { |
Implement pagination for boards, threads and replies.
Closes #3200
CC @jeronimoalbi @salmad3