fix: set offset correctly on thread message view (#5609)

This commit is contained in:
Gleidson Daniel Silva 2024-03-13 10:29:25 -03:00 committed by GitHub
parent b5cef460f5
commit afe50aed7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 4 deletions

View File

@ -48,6 +48,7 @@ interface IThreadMessagesViewState {
currentFilter: Filter;
isSearching: boolean;
searchText: string;
offset: number;
}
interface IThreadMessagesViewProps extends IBaseScreen<ChatsStackParamList, 'ThreadMessagesView'> {
@ -85,7 +86,8 @@ class ThreadMessagesView extends React.Component<IThreadMessagesViewProps, IThre
showFilterDropdown: false,
currentFilter: Filter.All,
isSearching: false,
searchText: ''
searchText: '',
offset: 0
};
this.setHeader();
this.initSubscription();
@ -308,7 +310,7 @@ class ThreadMessagesView extends React.Component<IThreadMessagesViewProps, IThre
// eslint-disable-next-line react/sort-comp
load = debounce(async (lastThreadSync: Date) => {
const { loading, end, messages, searchText } = this.state;
const { loading, end, searchText, offset } = this.state;
if (end || loading || !this.mounted) {
return;
}
@ -319,14 +321,15 @@ class ThreadMessagesView extends React.Component<IThreadMessagesViewProps, IThre
const result = await Services.getThreadsList({
rid: this.rid,
count: API_FETCH_COUNT,
offset: messages.length,
offset,
text: searchText
});
if (result.success) {
this.updateThreads({ update: result.threads, lastThreadSync });
this.setState({
loading: false,
end: result.count < API_FETCH_COUNT
end: result.count < API_FETCH_COUNT,
offset: offset + API_FETCH_COUNT
});
}
} catch (e) {