Skip to content

Commit

Permalink
fix: clean up mls query page size logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Normore committed Jan 12, 2024
1 parent 4d43cda commit 85f5f24
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions pkg/mls/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,10 @@ func (s *Store) QueryGroupMessagesV1(ctx context.Context, req *mlsv1.QueryGroupM
})
}

pagingInfo := &mlsv1.PagingInfo{Limit: 0, IdCursor: 0, Direction: direction}
pagingInfo := &mlsv1.PagingInfo{Limit: uint32(pageSize), IdCursor: 0, Direction: direction}
if len(messages) >= pageSize {
if len(messages) > 0 {
lastMsg := msgs[len(messages)-1]
pagingInfo.IdCursor = lastMsg.Id
}
lastMsg := msgs[len(messages)-1]
pagingInfo.IdCursor = lastMsg.Id
}

return &mlsv1.QueryGroupMessagesResponse{
Expand Down Expand Up @@ -338,12 +336,10 @@ func (s *Store) QueryWelcomeMessagesV1(ctx context.Context, req *mlsv1.QueryWelc
})
}

pagingInfo := &mlsv1.PagingInfo{Limit: 0, IdCursor: 0, Direction: direction}
pagingInfo := &mlsv1.PagingInfo{Limit: uint32(pageSize), IdCursor: 0, Direction: direction}
if len(messages) >= pageSize {
if len(messages) > 0 {
lastMsg := msgs[len(messages)-1]
pagingInfo.IdCursor = lastMsg.Id
}
lastMsg := msgs[len(messages)-1]
pagingInfo.IdCursor = lastMsg.Id
}

return &mlsv1.QueryWelcomeMessagesResponse{
Expand Down

0 comments on commit 85f5f24

Please sign in to comment.