spaceshelter / orbitar

Experimental collective social/blogging platform with self-regulation.
MIT License
59 stars 23 forks source link

Add updating post to fetch new comments when attempting to scroll... #332

Open Aivean opened 1 year ago

Aivean commented 1 year ago

…to a comment that is not fetched yet.

Demo: notif-demo

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

4vanger commented 1 year ago

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 https://github.com/spaceshelter/orbitar/pull/332#discussion_r1222342126:

@@ -59,6 +63,11 @@ export default function PostPage() { if (location.hash) { commentId = parseInt(location.hash.substring(1)); scrollToComment = document.querySelector([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 https://github.com/spaceshelter/orbitar/pull/332#discussion_r1222342126, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAERX7XW72NRWAOMW3SXDC3XKESEJANCNFSM6AAAAAAYTN2R3A . You are receiving this because your review was requested.Message ID: @.***>

Aivean commented 1 year ago

@4vanger

I'm almost done with this proposal ;)

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.