aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-06-03 18:28:56 +0800
committercrupest <crupest@outlook.com>2021-06-03 18:28:56 +0800
commit44141e188eef44fd4fd1c77aee7df168b68765b1 (patch)
treee8f8c55b578b4676e61511bf65ed4425e4f95d19 /FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
parent2cbb0aa75edbaf5269a4a3fdf52452834cf7ed04 (diff)
downloadtimeline-44141e188eef44fd4fd1c77aee7df168b68765b1.tar.gz
timeline-44141e188eef44fd4fd1c77aee7df168b68765b1.tar.bz2
timeline-44141e188eef44fd4fd1c77aee7df168b68765b1.zip
fix: Don't know this is No.which attemp to fix scroll to top bug.
Diffstat (limited to 'FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx')
-rw-r--r--FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx16
1 files changed, 5 insertions, 11 deletions
diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
index 69fd9207..37f02a82 100644
--- a/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
+++ b/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
@@ -1,8 +1,9 @@
import React from "react";
-import { fromEvent } from "rxjs";
import { HttpTimelinePostInfo } from "@/http/timeline";
+import useScrollToTop from "@/utilities/useScrollToTop";
+
import TimelinePostListView from "./TimelinePostListView";
export interface TimelinePagedPostListViewProps {
@@ -25,16 +26,9 @@ const TimelinePagedPostListView: React.FC<TimelinePagedPostListViewProps> = (
: posts.slice(-lastViewCount);
}, [posts, lastViewCount]);
- React.useEffect(() => {
- if (lastViewCount < posts.length) {
- const subscription = fromEvent(window, "scroll").subscribe(() => {
- if (window.scrollY === 0) {
- setLastViewCount(lastViewCount + 10);
- }
- });
- return () => subscription.unsubscribe();
- }
- }, [lastViewCount, posts]);
+ useScrollToTop(() => {
+ setLastViewCount(lastViewCount + 10);
+ }, lastViewCount < posts.length);
return (
<TimelinePostListView