fix: reach start in message feed
This commit is contained in:
@@ -64,8 +64,9 @@ const VirtualMessageFeed = ({ context, id }: Props) => {
|
|||||||
// }, [mids]);
|
// }, [mids]);
|
||||||
|
|
||||||
// 加载更多
|
// 加载更多
|
||||||
const handleLoadMore = useCallback(() => {
|
const handleTopStateChange = (isTop: boolean) => {
|
||||||
console.log("reach start ");
|
console.log("reach top ", isTop);
|
||||||
|
if (isTop) {
|
||||||
if (historyMid === "reached") return;
|
if (historyMid === "reached") return;
|
||||||
let lastMid = mids.slice(0, 1)[0];
|
let lastMid = mids.slice(0, 1)[0];
|
||||||
if (historyMid) {
|
if (historyMid) {
|
||||||
@@ -73,8 +74,8 @@ const VirtualMessageFeed = ({ context, id }: Props) => {
|
|||||||
}
|
}
|
||||||
// prevMids = mids;
|
// prevMids = mids;
|
||||||
loadMoreMessage({ context, id, mid: lastMid });
|
loadMoreMessage({ context, id, mid: lastMid });
|
||||||
// return false;
|
}
|
||||||
}, [mids, context, id]);
|
};
|
||||||
// 自动跟随
|
// 自动跟随
|
||||||
const handleFollowOutput = (isAtBottom: boolean) => {
|
const handleFollowOutput = (isAtBottom: boolean) => {
|
||||||
const [lastMid] = mids ? mids.slice(-1) : [0];
|
const [lastMid] = mids ? mids.slice(-1) : [0];
|
||||||
@@ -112,9 +113,10 @@ const VirtualMessageFeed = ({ context, id }: Props) => {
|
|||||||
}}
|
}}
|
||||||
// firstItemIndex={firstItemIndex}
|
// firstItemIndex={firstItemIndex}
|
||||||
initialTopMostItemIndex={mids.length - 1}
|
initialTopMostItemIndex={mids.length - 1}
|
||||||
startReached={handleLoadMore}
|
// startReached={handleLoadMore}
|
||||||
data={mids}
|
data={mids}
|
||||||
atTopThreshold={context == "channel" ? 160 : 0}
|
atTopThreshold={context == "channel" ? 160 : 0}
|
||||||
|
atTopStateChange={handleTopStateChange}
|
||||||
atBottomStateChange={handleBottomStateChange}
|
atBottomStateChange={handleBottomStateChange}
|
||||||
atBottomThreshold={400}
|
atBottomThreshold={400}
|
||||||
followOutput={handleFollowOutput}
|
followOutput={handleFollowOutput}
|
||||||
|
|||||||
Reference in New Issue
Block a user