-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add updating post to fetch new comments when attempting to scroll... #332
base: dev
Are you sure you want to change the base?
Conversation
…o a comment that is not fetched yet
@@ -59,6 +63,11 @@ export default function PostPage() { | |||
if (location.hash) { | |||
commentId = parseInt(location.hash.substring(1)); | |||
scrollToComment = document.querySelector<HTMLDivElement>(`[data-comment-id="${commentId}"]`); | |||
|
|||
if (!scrollToComment && fetchingComment !== commentId) { | |||
reload(unreadOnly).then(() => setFetchingComment(commentId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got your idea but this will reload the post by just clicking at the link which may be not something user wants - I often skip reading answers in big posts because I don't have enough time to read all of them right now. At least we should ask for user's confirmation
Second scenario - comment is not on the page because it is in read branch - in this case reloading won't show it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both cases can be fixed by relying on the last read timestamp/comment instead of the materialized "isNew" flag.
This allows performing the comment presence check easily, as well as loading the "new" comments without removing existing "new" comments from the page.
I'm almost done with this proposal ;)
…On Wed, Jun 7, 2023, 18:20 Ivan Zaitsev ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In frontend/src/Pages/PostPage.tsx
<#332 (comment)>:
> @@ -59,6 +63,11 @@ export default function PostPage() {
if (location.hash) {
commentId = parseInt(location.hash.substring(1));
scrollToComment = document.querySelector<HTMLDivElement>(`[data-comment-id="${commentId}"]`);
+
+ if (!scrollToComment && fetchingComment !== commentId) {
+ reload(unreadOnly).then(() => setFetchingComment(commentId));
I think both cases can be fixed by relying on the last read
timestamp/comment instead of the materialized "isNew" flag.
This allows performing the comment presence check easily, as well as
loading the "new" comments without removing existing "new" comments from
the page.
—
Reply to this email directly, view it on GitHub
<#332 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAERX7XW72NRWAOMW3SXDC3XKESEJANCNFSM6AAAAAAYTN2R3A>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
An idea for that: Instead of having two statuses for comments: "read" and "new", have three:
When page is loaded originally, comments are either "read" or "new". However, user has the ability to refresh the page or or follow notification link, which loads a batch of fresh comments. To distinguish between them and "new" comments that were already on the page, I suggest to introduce a new status with working name "previously new". When fresh comments are added to the page, the currently "new" comments will transition to the status "previously new", and freshly added comments will become "new". Obviously, both statuses are calculated based on the corresponding timestamp/last comment id. |
…to a comment that is not fetched yet.
Demo:

Tested some common scrolling scenarios, including scrolling to not existing hash.