kbin-kes icon indicating copy to clipboard operation
kbin-kes copied to clipboard

[FEAT] Implement collapsible replies on the microblog tab too

Open Pamasich opened this issue 10 months ago • 10 comments

Browser

Chromium-based

Script manager

Tampermonkey

KES version

4.3.0-beta.15

Describe the feature

The improved_collapsible_comments mod doesn't cureently apply to the Microblog view. Neither does Mbin have a native collapsing mechanic there. (besides toggling ALL replies to a post on or off)

Pamasich avatar Feb 14 '25 14:02 Pamasich

Kind of complicated, because threads on microblogs are groupings of top posts with comment sub-threads underneath them, rather than a single thread with all comments and sub-threads below it, so the traversal logic needs to be remade from scratch for those particular pages.

aclist avatar Feb 16 '25 13:02 aclist

Neither does Mbin have a native collapsing mechanic there. (besides toggling ALL replies to a post on or off)

There actually is a native functionality, so I was wrong there.

As such, we don't REALLY need to expand the mod to cover it. If it's that much work, this feature request should probably be shelved. I'll close this as not planned, you can reopen it if you do want to do it, but I don't think it's necessary after all.

Pamasich avatar Mar 04 '25 15:03 Pamasich

I don't think it's out of the question, just haven't taken a crack at gauging the feasibility yet. We have some more helper functions now that relate to microblogs, so it might be less complex than it seems. The mod just has a labyrinthine design, so haven't looked at it yet.

aclist avatar Mar 05 '25 03:03 aclist

Did some testing, and provided the selector is changed from .entry-comment to .post-comment, the mod mostly behaves the same on microblog pages. The caveat is that apparently, by design, microblogs only support one level of nesting when there is a chain of replies (unless I did something wrong). All replies to a microblog top post get put directly beneath the top post, even if the reply was being made as a reply under a reply.

What doesn't work OOTB is connecting these replies to the top post, since the mod is looking for a singular top post in a thread, rather than accounting for the possibility of multiple top posts.

Anyway, if we extend support to microblogs, it will just be a bunch of top posts with the ability to expand/collapse them, and all of the replies underneath them, so the mod is semi-useless insofar as replies can't be nested.

So, currently, with the fix, it behaves exactly like the native functionality:

  • Can't collapse the top post
  • Can individually collapse replies
  • Replies aren't nested

aclist avatar Mar 07 '25 07:03 aclist

Alternatively, could just leave a comment in the JSON description stating that it doesn't work on microblogs, if the above is seen as too pointless a feature.

aclist avatar Mar 07 '25 07:03 aclist

I've definitely seen nested replies, but yeah they seem to be a rarity. I wonder if it's just Mbin/Lemmy replies that are displayed nested.

See this example post I just made.

Image

Pamasich avatar Mar 07 '25 08:03 Pamasich

I did try making some dummy posts for the nesting, but couldn't get anywhere with it.

Maybe it's a setting? I'm logged out, MES is fully off, and here's what I see:

Image

aclist avatar Mar 07 '25 09:03 aclist

Ah, click on expand.

Also, regarding what I said above

I wonder if it's just Mbin/Lemmy replies that are displayed nested.

This isn't the case, Mastodon replies are nested too. I was looking at the most commented posts there and didn't see any nesting, but I guess that was probably just bad luck (or maybe it breaks with too many replies). I do see replies from Mastodon users when I look at my /sub feed's newest posts.

Pamasich avatar Mar 07 '25 09:03 Pamasich

Oh, got it. I keep forgetting that there's a link in the footer to expand.

The posts don't actually exist on the page; they get loaded dynamically. Collapse doesn't just hide the posts, either--it completely removes them from the tree, and they have to get fetched again each time expansion occurs.

On the plus side, we are already watching for mutations to this area (.post-comments) as of the last couple patches.

So it seems like it wouldn't be possible to just load a page for the first time with the posts expanded. It has to be manually triggered by the user, at which point the mutation would be caught.

So if the page === Mbin.Microblog:

  • If the posts aren't expanded, abort.
  • Otherwise, trigger on mutations automatically.
  • When toggling off, remove the styling.
  • If the user manually collapses the tree, it doesn't matter, because the posts are completely destroyed

aclist avatar Mar 07 '25 09:03 aclist

Got it working cleanly after some struggle (#501), so I'm reopening this.

aclist avatar Mar 07 '25 13:03 aclist