Skip to content

Commit ae7d6a7

Browse files
author
Sravan S
authored
fix: Fetch more messages even if result size is larger(#688)
In Channel, for some customers, the server returns 32 messages even when we asked for 31. Even though its an issue coming from server, we shouldnt set `hasMorePrev` to false when result size is larger than query Fixes: https://sendbird.atlassian.net/browse/SBISSUE-12994 Fixes: https://sendbird.atlassian.net/browse/CLNP-349
1 parent 4a28ace commit ae7d6a7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/modules/Channel/context/dux/__tests__/reducers.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('Messages-Reducers', () => {
126126
expect(nextState.hasMoreNext).toEqual(true);
127127
});
128128

129-
it('should validate unexpected additional messages are fetched FETCH_PREV_MESSAGES_SUCCESS', () => {
129+
it('should not set `hasMorePrev: false` when additional messages are fetched in FETCH_PREV_MESSAGES_SUCCESS', () => {
130130
// request size < response size
131131
const MESSAGE_LIST_SIZE = 20;
132132
const mockData = generateMockChannel();
@@ -145,7 +145,7 @@ describe('Messages-Reducers', () => {
145145
messages: new Array(MESSAGE_LIST_SIZE + 1).fill({}),
146146
}
147147
});
148-
expect(nextState.hasMorePrev).toEqual(false);
148+
expect(nextState.hasMorePrev).toEqual(true);
149149
expect(nextState.hasMoreNext).toEqual(true);
150150
});
151151

src/modules/Channel/context/dux/reducers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function reducer(state, action) {
7070
return state;
7171
}
7272
const hasMorePrev = ((messages?.length ?? 0)
73-
=== (state?.messageListParams?.prevResultSize ?? PREV_RESULT_SIZE) + 1);
73+
>= (state?.messageListParams?.prevResultSize ?? PREV_RESULT_SIZE) + 1);
7474
const oldestMessageTimeStamp = getOldestMessageTimeStamp(messages);
7575

7676
// Remove duplicated messages

0 commit comments

Comments
 (0)