mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 17:53:55 +08:00
Excluding small actions from a topic's counters (#40481) also excluded them from `highest_post_number` / `highest_staff_post_number`, which are the ceiling that `topic_users.last_read_post_number` is clamped to. As a result, a topic whose last post is a small action (a close, pin, archive, etc. notice) could never be read past that notice: the "last visit" line stayed above it on every visit and the topic never read as fully caught up (https://meta.discourse.org/t/-/404058). The root cause is that `highest_post_number` quietly served two roles — the highest post worth *notifying* about, and the highest post a user can *see* (the read-position ceiling). Those were only ever the same value because small actions used to count toward both. Dropping them from the columns is correct for the first role but wrong for the second: small actions are visible to everyone and occupy real stream positions that get read. This keeps the columns meaning "highest notify-worthy post" — so `/unread`, the unread badge, and watched notifications stay correct and cheap — and derives "highest post in the visible stream" wherever a read position is written. That value includes small actions (and whispers only for whisperers) and lives in `Topic.highest_post_number_in_stream`; every read-tracking path now goes through it: recording timings, the `last_read` clamp, `reset_highest`, `dismiss_posts`, the close/auto-close `pretend_read` target, nested-topic catch-up, and the post-merge caught-up detection. Because `last_read_post_number` can now legitimately exceed the notify counter, a few checks that assumed the two were equal became `>=` (the private-message read indicator, the topic model's `visited` / `canClearPin`, and the client-side tracking state). Finally, `process_timings` computes the visible-stream ceiling once and threads it into `update_last_read`, so the clamp no longer re-derives it and the hottest read path stays a single index-backed `MAX(post_number)`. |
||
|---|---|---|
| .. | ||
| db | ||
| fabricators | ||
| fixtures | ||
| generator | ||
| helpers | ||
| import_export | ||
| initializers | ||
| integration | ||
| integrity | ||
| jobs | ||
| lib | ||
| mailers | ||
| migrations | ||
| models | ||
| multisite | ||
| queries/reports | ||
| requests | ||
| script | ||
| serializers | ||
| services | ||
| support | ||
| system | ||
| tasks | ||
| views | ||
| rails_helper.rb | ||
| regenerate_swagger_docs | ||
| swagger_helper.rb | ||