Skip to content

Commit 3643e53

Browse files
committed
Fixed prepend posts not working correctly
1 parent abdb289 commit 3643e53

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/components/post_search/columns/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export default function ColumnPosts(props) {
5353

5454
let scrollHandler = (e) => {
5555
const { scrollTop, offsetHeight, scrollHeight } = e.target;
56-
if (scrollTop + offsetHeight >= scrollHeight) {
56+
let distanceFromTop = scrollTop + offsetHeight;
57+
let distanceFromBottom = scrollHeight - distanceFromTop;
58+
if (distanceFromBottom === 0) {
5759
posts_callback();
5860
}
5961
};

src/components/post_search/grid/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function GridPosts(props) {
2727
const { scrollTop, offsetHeight, scrollHeight } = e.target;
2828
let distanceFromTop = scrollTop + offsetHeight;
2929
let distanceFromBottom = scrollHeight - distanceFromTop;
30-
if (distanceFromBottom < 2) {
30+
if (distanceFromBottom === 0) {
3131
posts_callback();
3232
}
3333
};

src/components/post_search/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import LayoutSelector from "./layout_selector";
66
import Settings from "js/settings";
77

88
export default function PostsSearch(props) {
9-
let { search,layout } = props;
9+
let { search, layout } = props;
1010
let [ posts, setPosts ] = useState([]);
1111

1212
useEffect(() => {
@@ -15,10 +15,12 @@ export default function PostsSearch(props) {
1515
setPosts(search.posts);
1616
})()
1717
}, []);
18-
18+
1919
function prepend_posts() {
20-
search.extend(100);
21-
setPosts(search.posts);
20+
(async () => {
21+
await search.extend(100);
22+
setPosts(search.posts);
23+
})();
2224
}
2325

2426
let Layout_Lookup = {

0 commit comments

Comments
 (0)