1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Add navigation to last/first page

This commit is contained in:
Wojtek 2024-06-29 05:19:38 +02:00 committed by GitHub
parent f0e8323f19
commit a46e702536
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 109 additions and 16 deletions

View file

@ -9,17 +9,30 @@ type pagination struct {
Offset int
ItemsPerPage int
ShowNext bool
ShowLast bool
ShowFirst bool
ShowPrev bool
NextOffset int
LastOffset int
PrevOffset int
FirstOffset int
SearchQuery string
}
func getPagination(route string, total, offset, nbItemsPerPage int) pagination {
nextOffset := 0
prevOffset := 0
firstOffset := 0
lastOffset := (total / nbItemsPerPage) * nbItemsPerPage
if lastOffset == total {
lastOffset -= nbItemsPerPage
}
showNext := (total - offset) > nbItemsPerPage
showPrev := offset > 0
showLast := showNext
showFirst := showPrev
if showNext {
nextOffset = offset + nbItemsPerPage
@ -35,8 +48,12 @@ func getPagination(route string, total, offset, nbItemsPerPage int) pagination {
Offset: offset,
ItemsPerPage: nbItemsPerPage,
ShowNext: showNext,
ShowLast: showLast,
NextOffset: nextOffset,
LastOffset: lastOffset,
ShowPrev: showPrev,
ShowFirst: showFirst,
PrevOffset: prevOffset,
FirstOffset: firstOffset,
}
}