PostStreamScrubber shows "0 UNREAD" when reply composer is open
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
- Login
- Open a discussion
- Scroll to the bottom to mark all posts as read
- Open the reply composer
Expected Behavior
"0 UNREAD" should be hidden, like it was in previous flarum versions.
Screenshots
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
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..
It seems to evaluate to a negative value for me locally.
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.