Improve mobile UI and add infinite scroll
This commit is contained in:
@@ -99,3 +99,21 @@ func FilterResultRows(rows []ResultRow, search, filter string) []ResultRow {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func PaginateResultRows(rows []ResultRow, page, pageSize int) ([]ResultRow, bool) {
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
if pageSize < 1 {
|
||||
pageSize = 30
|
||||
}
|
||||
start := (page - 1) * pageSize
|
||||
if start >= len(rows) {
|
||||
return []ResultRow{}, false
|
||||
}
|
||||
end := start + pageSize
|
||||
if end > len(rows) {
|
||||
end = len(rows)
|
||||
}
|
||||
return rows[start:end], end < len(rows)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user