Skip to content

Commit

Permalink
fix: fix paging issue for page size 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimbbakar committed Aug 20, 2022
1 parent 87dff8b commit 6309614
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions service/note.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (n *NoteService) ListCommand(curPage int) []Note {
repo := repository.GetNewLocalStorage()

limit := utils.ParseInt(repo.GetConfig("per_page"))
start, end, limit := curPage*limit, (curPage+1)*limit, limit
start, end, limit := curPage*limit, (curPage+1)*limit-1, limit
markedOnly := utils.ParseBoolean(repo.GetConfig("marked_only"))
noteList := []Note{}

Expand All @@ -79,13 +79,12 @@ func (n *NoteService) ListCommand(curPage int) []Note {
response(err.Error(), true, false, true)
}

for i := len(notes) - 1; i >= 0 && limit > 0; i-- {
for i := len(notes) - 1; i >= 0 && limit > 0; i, count = i-1, count+1 {
deleted := utils.ParseBoolean(notes[i][DELETED])
if err != nil {
response(err.Error(), true, false, true)
}

count++
if !(start <= count && count <= end) {
continue
} else if markedOnly && deleted {
Expand Down

0 comments on commit 6309614

Please sign in to comment.