Skip to content

Commit eec3cd7

Browse files
committed
feat: return default message set pagination if not available
1 parent f9431b2 commit eec3cd7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/channel_state.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
UserResponse,
1616
} from './types';
1717
import { addToMessageList } from './utils';
18+
import {DEFAULT_MESSAGE_SET_PAGINATION} from "./constants";
1819

1920
type ChannelReadStatus<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Record<
2021
string,
@@ -106,7 +107,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
106107
}
107108

108109
get messagePagination() {
109-
return this.messageSets.find((s) => s.isCurrent)?.pagination || {};
110+
return this.messageSets.find((s) => s.isCurrent)?.pagination || DEFAULT_MESSAGE_SET_PAGINATION;
110111
}
111112

112113
/**
@@ -719,7 +720,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
719720

720721
initMessages() {
721722
this.messageSets = [
722-
{ messages: [], isLatest: true, isCurrent: true, pagination: { hasNext: true, hasPrev: true } },
723+
{ messages: [], isLatest: true, isCurrent: true, pagination: DEFAULT_MESSAGE_SET_PAGINATION },
723724
];
724725
}
725726

@@ -828,7 +829,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
828829
messages: [],
829830
isCurrent: false,
830831
isLatest: false,
831-
pagination: { hasNext: true, hasPrev: true },
832+
pagination: DEFAULT_MESSAGE_SET_PAGINATION,
832833
});
833834
targetMessageSetIndex = this.messageSets.length - 1;
834835
}

src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export const DEFAULT_QUERY_CHANNELS_MESSAGE_LIST_PAGE_SIZE = 25;
22
export const DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE = 100;
3+
4+
export const DEFAULT_MESSAGE_SET_PAGINATION = { hasNext: true, hasPrev: true };

0 commit comments

Comments
 (0)