Skip to content

Commit

Permalink
fix: set offset correctly on thread message view (#5609)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlsilva authored Mar 13, 2024
1 parent b5cef46 commit afe50ae
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/views/ThreadMessagesView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ interface IThreadMessagesViewState {
currentFilter: Filter;
isSearching: boolean;
searchText: string;
offset: number;
}

interface IThreadMessagesViewProps extends IBaseScreen<ChatsStackParamList, 'ThreadMessagesView'> {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down

0 comments on commit afe50ae

Please sign in to comment.