Skip to content

Commit c4333cf

Browse files
HoonBaeksravan-s
authored andcommitted
fix: Expect not to be accurate height of channel list (#349)
1 parent dd50d68 commit c4333cf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/smart-components/ChannelList/components/ChannelListUI/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as channelListActions from '../../dux/actionTypes';
1414
import useSendbirdStateContext from '../../../../hooks/useSendbirdStateContext';
1515
import EditUserProfile from '../../../EditUserProfile';
1616
import PlaceHolder, { PlaceHolderTypes } from '../../../../ui/PlaceHolder';
17+
import { isAboutSame } from '../utils';
1718

1819
const DELIVERY_RECIPT = 'delivery_receipt';
1920

@@ -126,7 +127,7 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (props: ChannelListUIProps)
126127
className="sendbird-channel-list__body"
127128
onScroll={(e) => {
128129
const target = e?.target as HTMLDivElement;
129-
const fetchMore = target.clientHeight + target.scrollTop === target.scrollHeight;
130+
const fetchMore = isAboutSame(target.clientHeight + target.scrollTop, target.scrollHeight, 10);
130131
if (fetchMore && channelSource?.hasNext) {
131132
logger.info('ChannelList: Fetching more channels');
132133
channelListDispatcher({

src/smart-components/ChannelList/components/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export const isSuperGroupChannelEnabled = (sdk = {}) => {
3838
return false;
3939
};
4040

41+
export const isAboutSame = (a, b, px) => (Math.abs(a - b) <= px);
42+
4143
export const setChannelType = (params, type) => {
4244
if (type === 'broadcast') {
4345
// eslint-disable-next-line no-param-reassign

0 commit comments

Comments
 (0)