pagination: remove empty models
This commit is contained in:
@ -9,13 +9,15 @@ export function paginateModels(models) {
|
||||
let currentSize = 0
|
||||
let currentPage = []
|
||||
for (let model of models) {
|
||||
currentSize += model.size
|
||||
if (currentSize > 3) {
|
||||
pages.push(currentPage)
|
||||
currentPage = [model]
|
||||
currentSize = model.size
|
||||
} else {
|
||||
currentPage.push(model)
|
||||
if (model.size > 0) { // skip empty models
|
||||
currentSize += model.size
|
||||
if (currentSize > 3) {
|
||||
pages.push(currentPage)
|
||||
currentPage = [model]
|
||||
currentSize = model.size
|
||||
} else {
|
||||
currentPage.push(model)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentPage.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user