aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FrontEnd/package-lock.json235
-rw-r--r--FrontEnd/package.json2
-rw-r--r--FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts62
-rw-r--r--FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx35
4 files changed, 109 insertions, 225 deletions
diff --git a/FrontEnd/package-lock.json b/FrontEnd/package-lock.json
index 977a0c8e..d285d6b8 100644
--- a/FrontEnd/package-lock.json
+++ b/FrontEnd/package-lock.json
@@ -61,7 +61,7 @@
"@types/remarkable": "^2.0.1",
"@types/webpack-env": "^1.16.0",
"@types/xregexp": "^4.3.0",
- "@typescript-eslint/eslint-plugin": "^4.22.0",
+ "@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1",
"@yarnpkg/pnpify": "^2.4.0",
"babel-loader": "^8.2.2",
@@ -2282,13 +2282,13 @@
"dev": true
},
"node_modules/@typescript-eslint/eslint-plugin": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.0.tgz",
- "integrity": "sha512-U8SP9VOs275iDXaL08Ln1Fa/wLXfj5aTr/1c0t0j6CdbOnxh+TruXu1p4I0NAvdPBQgoPjHsgKn28mOi0FzfoA==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.1.tgz",
+ "integrity": "sha512-kVTAghWDDhsvQ602tHBc6WmQkdaYbkcTwZu+7l24jtJiYvm9l+/y/b2BZANEezxPDiX5MK2ZecE+9BFi/YJryw==",
"dev": true,
"dependencies": {
- "@typescript-eslint/experimental-utils": "4.22.0",
- "@typescript-eslint/scope-manager": "4.22.0",
+ "@typescript-eslint/experimental-utils": "4.22.1",
+ "@typescript-eslint/scope-manager": "4.22.1",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"lodash": "^4.17.15",
@@ -2329,15 +2329,15 @@
}
},
"node_modules/@typescript-eslint/experimental-utils": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.22.0.tgz",
- "integrity": "sha512-xJXHHl6TuAxB5AWiVrGhvbGL8/hbiCQ8FiWwObO3r0fnvBdrbWEDy1hlvGQOAWc6qsCWuWMKdVWlLAEMpxnddg==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.22.1.tgz",
+ "integrity": "sha512-svYlHecSMCQGDO2qN1v477ax/IDQwWhc7PRBiwAdAMJE7GXk5stF4Z9R/8wbRkuX/5e9dHqbIWxjeOjckK3wLQ==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.3",
- "@typescript-eslint/scope-manager": "4.22.0",
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/typescript-estree": "4.22.0",
+ "@typescript-eslint/scope-manager": "4.22.1",
+ "@typescript-eslint/types": "4.22.1",
+ "@typescript-eslint/typescript-estree": "4.22.1",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
},
@@ -2379,7 +2379,7 @@
}
}
},
- "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": {
+ "node_modules/@typescript-eslint/scope-manager": {
"version": "4.22.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.22.1.tgz",
"integrity": "sha512-d5bAiPBiessSmNi8Amq/RuLslvcumxLmyhf1/Xa9IuaoFJ0YtshlJKxhlbY7l2JdEk3wS0EnmnfeJWSvADOe0g==",
@@ -2396,7 +2396,7 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
- "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": {
+ "node_modules/@typescript-eslint/types": {
"version": "4.22.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.22.1.tgz",
"integrity": "sha512-2HTkbkdAeI3OOcWbqA8hWf/7z9c6gkmnWNGz0dKSLYLWywUlkOAQ2XcjhlKLj5xBFDf8FgAOF5aQbnLRvgNbCw==",
@@ -2409,7 +2409,7 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
- "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": {
+ "node_modules/@typescript-eslint/typescript-estree": {
"version": "4.22.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.1.tgz",
"integrity": "sha512-p3We0pAPacT+onSGM+sPR+M9CblVqdA9F1JEdIqRVlxK5Qth4ochXQgIyb9daBomyQKAXbygxp1aXQRV0GC79A==",
@@ -2436,95 +2436,6 @@
}
}
},
- "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": {
- "version": "4.22.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.1.tgz",
- "integrity": "sha512-WPkOrIRm+WCLZxXQHCi+WG8T2MMTUFR70rWjdWYddLT7cEfb2P4a3O/J2U1FBVsSFTocXLCoXWY6MZGejeStvQ==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "4.22.1",
- "eslint-visitor-keys": "^2.0.0"
- },
- "engines": {
- "node": "^8.10.0 || ^10.13.0 || >=11.10.1"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/parser/node_modules/semver": {
- "version": "7.3.5",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
- "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
- "dev": true,
- "dependencies": {
- "lru-cache": "^6.0.0"
- },
- "bin": {
- "semver": "bin/semver.js"
- },
- "engines": {
- "node": ">=10"
- }
- },
- "node_modules/@typescript-eslint/scope-manager": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.22.0.tgz",
- "integrity": "sha512-OcCO7LTdk6ukawUM40wo61WdeoA7NM/zaoq1/2cs13M7GyiF+T4rxuA4xM+6LeHWjWbss7hkGXjFDRcKD4O04Q==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/visitor-keys": "4.22.0"
- },
- "engines": {
- "node": "^8.10.0 || ^10.13.0 || >=11.10.1"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/types": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.22.0.tgz",
- "integrity": "sha512-sW/BiXmmyMqDPO2kpOhSy2Py5w6KvRRsKZnV0c4+0nr4GIcedJwXAq+RHNK4lLVEZAJYFltnnk1tJSlbeS9lYA==",
- "dev": true,
- "engines": {
- "node": "^8.10.0 || ^10.13.0 || >=11.10.1"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/typescript-estree": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.0.tgz",
- "integrity": "sha512-TkIFeu5JEeSs5ze/4NID+PIcVjgoU3cUQUIZnH3Sb1cEn1lBo7StSV5bwPuJQuoxKXlzAObjYTilOEKRuhR5yg==",
- "dev": true,
- "dependencies": {
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/visitor-keys": "4.22.0",
- "debug": "^4.1.1",
- "globby": "^11.0.1",
- "is-glob": "^4.0.1",
- "semver": "^7.3.2",
- "tsutils": "^3.17.1"
- },
- "engines": {
- "node": "^10.12.0 || >=12.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- },
- "peerDependenciesMeta": {
- "typescript": {
- "optional": true
- }
- }
- },
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
"version": "7.3.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
@@ -2541,12 +2452,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.0.tgz",
- "integrity": "sha512-nnMu4F+s4o0sll6cBSsTeVsT4cwxB7zECK3dFxzEjPBii9xLpq4yqqsy/FU5zMfan6G60DKZSCXAa3sHJZrcYw==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.1.tgz",
+ "integrity": "sha512-WPkOrIRm+WCLZxXQHCi+WG8T2MMTUFR70rWjdWYddLT7cEfb2P4a3O/J2U1FBVsSFTocXLCoXWY6MZGejeStvQ==",
"dev": true,
"dependencies": {
- "@typescript-eslint/types": "4.22.0",
+ "@typescript-eslint/types": "4.22.1",
"eslint-visitor-keys": "^2.0.0"
},
"engines": {
@@ -18068,13 +17979,13 @@
"dev": true
},
"@typescript-eslint/eslint-plugin": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.0.tgz",
- "integrity": "sha512-U8SP9VOs275iDXaL08Ln1Fa/wLXfj5aTr/1c0t0j6CdbOnxh+TruXu1p4I0NAvdPBQgoPjHsgKn28mOi0FzfoA==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.1.tgz",
+ "integrity": "sha512-kVTAghWDDhsvQ602tHBc6WmQkdaYbkcTwZu+7l24jtJiYvm9l+/y/b2BZANEezxPDiX5MK2ZecE+9BFi/YJryw==",
"dev": true,
"requires": {
- "@typescript-eslint/experimental-utils": "4.22.0",
- "@typescript-eslint/scope-manager": "4.22.0",
+ "@typescript-eslint/experimental-utils": "4.22.1",
+ "@typescript-eslint/scope-manager": "4.22.1",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"lodash": "^4.17.15",
@@ -18095,15 +18006,15 @@
}
},
"@typescript-eslint/experimental-utils": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.22.0.tgz",
- "integrity": "sha512-xJXHHl6TuAxB5AWiVrGhvbGL8/hbiCQ8FiWwObO3r0fnvBdrbWEDy1hlvGQOAWc6qsCWuWMKdVWlLAEMpxnddg==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.22.1.tgz",
+ "integrity": "sha512-svYlHecSMCQGDO2qN1v477ax/IDQwWhc7PRBiwAdAMJE7GXk5stF4Z9R/8wbRkuX/5e9dHqbIWxjeOjckK3wLQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
- "@typescript-eslint/scope-manager": "4.22.0",
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/typescript-estree": "4.22.0",
+ "@typescript-eslint/scope-manager": "4.22.1",
+ "@typescript-eslint/types": "4.22.1",
+ "@typescript-eslint/typescript-estree": "4.22.1",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
}
@@ -18118,84 +18029,32 @@
"@typescript-eslint/types": "4.22.1",
"@typescript-eslint/typescript-estree": "4.22.1",
"debug": "^4.1.1"
- },
- "dependencies": {
- "@typescript-eslint/scope-manager": {
- "version": "4.22.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.22.1.tgz",
- "integrity": "sha512-d5bAiPBiessSmNi8Amq/RuLslvcumxLmyhf1/Xa9IuaoFJ0YtshlJKxhlbY7l2JdEk3wS0EnmnfeJWSvADOe0g==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "4.22.1",
- "@typescript-eslint/visitor-keys": "4.22.1"
- }
- },
- "@typescript-eslint/types": {
- "version": "4.22.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.22.1.tgz",
- "integrity": "sha512-2HTkbkdAeI3OOcWbqA8hWf/7z9c6gkmnWNGz0dKSLYLWywUlkOAQ2XcjhlKLj5xBFDf8FgAOF5aQbnLRvgNbCw==",
- "dev": true
- },
- "@typescript-eslint/typescript-estree": {
- "version": "4.22.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.1.tgz",
- "integrity": "sha512-p3We0pAPacT+onSGM+sPR+M9CblVqdA9F1JEdIqRVlxK5Qth4ochXQgIyb9daBomyQKAXbygxp1aXQRV0GC79A==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "4.22.1",
- "@typescript-eslint/visitor-keys": "4.22.1",
- "debug": "^4.1.1",
- "globby": "^11.0.1",
- "is-glob": "^4.0.1",
- "semver": "^7.3.2",
- "tsutils": "^3.17.1"
- }
- },
- "@typescript-eslint/visitor-keys": {
- "version": "4.22.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.1.tgz",
- "integrity": "sha512-WPkOrIRm+WCLZxXQHCi+WG8T2MMTUFR70rWjdWYddLT7cEfb2P4a3O/J2U1FBVsSFTocXLCoXWY6MZGejeStvQ==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "4.22.1",
- "eslint-visitor-keys": "^2.0.0"
- }
- },
- "semver": {
- "version": "7.3.5",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
- "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
- "dev": true,
- "requires": {
- "lru-cache": "^6.0.0"
- }
- }
}
},
"@typescript-eslint/scope-manager": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.22.0.tgz",
- "integrity": "sha512-OcCO7LTdk6ukawUM40wo61WdeoA7NM/zaoq1/2cs13M7GyiF+T4rxuA4xM+6LeHWjWbss7hkGXjFDRcKD4O04Q==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.22.1.tgz",
+ "integrity": "sha512-d5bAiPBiessSmNi8Amq/RuLslvcumxLmyhf1/Xa9IuaoFJ0YtshlJKxhlbY7l2JdEk3wS0EnmnfeJWSvADOe0g==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/visitor-keys": "4.22.0"
+ "@typescript-eslint/types": "4.22.1",
+ "@typescript-eslint/visitor-keys": "4.22.1"
}
},
"@typescript-eslint/types": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.22.0.tgz",
- "integrity": "sha512-sW/BiXmmyMqDPO2kpOhSy2Py5w6KvRRsKZnV0c4+0nr4GIcedJwXAq+RHNK4lLVEZAJYFltnnk1tJSlbeS9lYA==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.22.1.tgz",
+ "integrity": "sha512-2HTkbkdAeI3OOcWbqA8hWf/7z9c6gkmnWNGz0dKSLYLWywUlkOAQ2XcjhlKLj5xBFDf8FgAOF5aQbnLRvgNbCw==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.0.tgz",
- "integrity": "sha512-TkIFeu5JEeSs5ze/4NID+PIcVjgoU3cUQUIZnH3Sb1cEn1lBo7StSV5bwPuJQuoxKXlzAObjYTilOEKRuhR5yg==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.1.tgz",
+ "integrity": "sha512-p3We0pAPacT+onSGM+sPR+M9CblVqdA9F1JEdIqRVlxK5Qth4ochXQgIyb9daBomyQKAXbygxp1aXQRV0GC79A==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "4.22.0",
- "@typescript-eslint/visitor-keys": "4.22.0",
+ "@typescript-eslint/types": "4.22.1",
+ "@typescript-eslint/visitor-keys": "4.22.1",
"debug": "^4.1.1",
"globby": "^11.0.1",
"is-glob": "^4.0.1",
@@ -18215,12 +18074,12 @@
}
},
"@typescript-eslint/visitor-keys": {
- "version": "4.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.0.tgz",
- "integrity": "sha512-nnMu4F+s4o0sll6cBSsTeVsT4cwxB7zECK3dFxzEjPBii9xLpq4yqqsy/FU5zMfan6G60DKZSCXAa3sHJZrcYw==",
+ "version": "4.22.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.1.tgz",
+ "integrity": "sha512-WPkOrIRm+WCLZxXQHCi+WG8T2MMTUFR70rWjdWYddLT7cEfb2P4a3O/J2U1FBVsSFTocXLCoXWY6MZGejeStvQ==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "4.22.0",
+ "@typescript-eslint/types": "4.22.1",
"eslint-visitor-keys": "^2.0.0"
}
},
diff --git a/FrontEnd/package.json b/FrontEnd/package.json
index 4f12336b..bb059000 100644
--- a/FrontEnd/package.json
+++ b/FrontEnd/package.json
@@ -76,7 +76,7 @@
"@types/remarkable": "^2.0.1",
"@types/webpack-env": "^1.16.0",
"@types/xregexp": "^4.3.0",
- "@typescript-eslint/eslint-plugin": "^4.22.0",
+ "@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1",
"@yarnpkg/pnpify": "^2.4.0",
"babel-loader": "^8.2.2",
diff --git a/FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts b/FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts
index 67c7c458..742751eb 100644
--- a/FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts
+++ b/FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts
@@ -1,39 +1,47 @@
import React from "react";
let on = false;
+let recordDisabled = false;
+
+function getScrollPosition(): number {
+ if (document.documentElement.scrollHeight <= window.innerHeight) {
+ return 0;
+ } else {
+ return (
+ document.documentElement.scrollHeight -
+ document.documentElement.scrollTop -
+ window.innerHeight
+ );
+ }
+}
+
+let scrollPosition = getScrollPosition();
+
+function scrollToRecordPosition(): void {
+ if (document.documentElement.scrollHeight <= window.innerHeight) return;
+ document.documentElement.scrollTop =
+ document.documentElement.scrollHeight - window.innerHeight - scrollPosition;
+}
+
+const scrollListener = (): void => {
+ if (recordDisabled) return;
+ scrollPosition = getScrollPosition();
+};
+
+const resizeObserver = new ResizeObserver(() => {
+ scrollToRecordPosition();
+});
+
+export function setRecordDisabled(disabled: boolean): void {
+ recordDisabled = disabled;
+ if (!disabled) scrollToRecordPosition();
+}
export default function useReverseScrollPositionRemember(): void {
React.useEffect(() => {
if (on) return;
on = true;
-
- function getScrollPosition(): number {
- if (document.documentElement.scrollHeight <= window.innerHeight) {
- return 0;
- } else {
- return (
- document.documentElement.scrollHeight -
- document.documentElement.scrollTop -
- window.innerHeight
- );
- }
- }
-
- let scrollPosition = getScrollPosition();
- const scrollListener = (): void => {
- scrollPosition = getScrollPosition();
- };
-
window.addEventListener("scroll", scrollListener);
-
- const resizeObserver = new ResizeObserver(() => {
- if (document.documentElement.scrollHeight <= window.innerHeight) return;
- document.documentElement.scrollTop =
- document.documentElement.scrollHeight -
- window.innerHeight -
- scrollPosition;
- });
-
resizeObserver.observe(document.documentElement);
return () => {
diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
index b44a8ef6..ee52f4c0 100644
--- a/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
+++ b/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
@@ -1,8 +1,11 @@
import React from "react";
+import { fromEvent } from "rxjs";
+import { filter, throttleTime } from "rxjs/operators";
import { HttpTimelinePostInfo } from "@/http/timeline";
import TimelinePostListView from "./TimelinePostListView";
+import { setRecordDisabled } from "@/utilities/useReverseScrollPositionRemember";
export interface TimelinePagedPostListViewProps {
className?: string;
@@ -24,18 +27,32 @@ const TimelinePagedPostListView: React.FC<TimelinePagedPostListViewProps> = (
: posts.slice(-lastViewCount);
}, [posts, lastViewCount]);
+ const scrollTopHandler = React.useRef<() => void>();
+
React.useEffect(() => {
- if (lastViewCount < posts.length) {
- const listener = (): void => {
- if (window.scrollY === 0 && lastViewCount < posts.length) {
- setLastViewCount(lastViewCount + 10);
- }
- };
- window.addEventListener("scroll", listener);
- return () => window.removeEventListener("scroll", listener);
- }
+ scrollTopHandler.current = () => {
+ if (lastViewCount < posts.length) {
+ setRecordDisabled(true);
+ setLastViewCount(lastViewCount + 10);
+ setTimeout(() => {
+ setRecordDisabled(false);
+ }, 500);
+ }
+ };
}, [lastViewCount, posts]);
+ React.useEffect(() => {
+ const subscription = fromEvent(window, "scroll")
+ .pipe(
+ filter(() => window.scrollY === 0),
+ throttleTime(800)
+ )
+ .subscribe(() => {
+ scrollTopHandler.current?.();
+ });
+ return () => subscription.unsubscribe();
+ }, []);
+
return (
<TimelinePostListView
className={className}