mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Publish read state on group messages. (#7989)
* Enable or disable read state based on group attribute * When read state needs to be published, the minimum unread count is calculated in the topic query. This way, we can know if someone reads the last post * The option can be enabled/disabled from the UI * The read indicator will live-updated using message bus * Show read indicator on every post * The read indicator now shows read count and can be expanded to see user avatars * Read count gets updated everytime someone reads a message * Simplify topic-list read indicator logic * Unsubscribe from message bus on willDestroyElement, removed unnecesarry values from post-menu, and added a comment to explain where does minimum_unread_count comes from
This commit is contained in:
@@ -26,6 +26,7 @@ class PostSerializer < BasicPostSerializer
|
||||
:quote_count,
|
||||
:incoming_link_count,
|
||||
:reads,
|
||||
:readers_count,
|
||||
:score,
|
||||
:yours,
|
||||
:topic_id,
|
||||
@@ -458,6 +459,13 @@ class PostSerializer < BasicPostSerializer
|
||||
can_review_topic?
|
||||
end
|
||||
|
||||
def readers_count
|
||||
read_count = object.reads - 1 # Exclude logged user
|
||||
read_count -= 1 unless yours
|
||||
|
||||
read_count < 0 ? 0 : read_count
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def can_review_topic?
|
||||
|
||||
Reference in New Issue
Block a user