framework icon indicating copy to clipboard operation
framework copied to clipboard

PostStreamScrubber shows "0 UNREAD" when reply composer is open

Open iPurpl3x opened this issue 2 years ago • 2 comments

Current Behavior

When a logged in user has read all the posts of a discussion and opens the reply composer, the PostStreamScrubber unnecessarily shows "0 UNREAD".

Steps to Reproduce

  1. Login
  2. Open a discussion
  3. Scroll to the bottom to mark all posts as read
  4. Open the reply composer

Expected Behavior

"0 UNREAD" should be hidden, like it was in previous flarum versions.

Screenshots

image

Environment

  • Flarum version: 1.8.1
  • Website URL: https://discuss.flarum.org

Output of php flarum info

No response

Possible Solution

No response

Additional Context

No response

iPurpl3x avatar Jun 21 '23 12:06 iPurpl3x

This is the commit that is causing this issue: https://github.com/flarum/framework/commit/11aa7bbb3511f7b6d4e676213fc708f1de598848

opacity: unreadPercent ? 1 : 0,

When there aren't any new unread posts, for some reason unreadPercent is evaluated true only when the composer opens..

gianniguida avatar Jun 21 '23 12:06 gianniguida

It seems to evaluate to a negative value for me locally.

image

That is caused by

const unreadPercent = count ? Math.min(count - this.stream.index, unreadCount) / count : 0;

Where the index is increased by 1 for the draft post, being more than the count itself.

luceos avatar Jun 26 '23 21:06 luceos