From 85f5f247e0e439c8ccc53b9c9a1980e1a24e4e13 Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Fri, 12 Jan 2024 18:18:24 -0500 Subject: [PATCH] fix: clean up mls query page size logic --- pkg/mls/store/store.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index 6df1c88f..8e64318b 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -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{ @@ -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{