FIX: show status on mentions on just posted posts (#19639)

We show live user status on mentions starting from a76d864. But status didn’t appear on the post that appears on the bottom of the topic just after a user posted it (status appeared only after page reloading). This adds status to just posted posts.
This commit is contained in:
Andrei Prigorshnev
2022-12-29 14:34:59 +04:00
committed by GitHub
parent f7cfffa043
commit 5e844793d8
2 changed files with 81 additions and 5 deletions

View File

@@ -563,13 +563,14 @@ class PostSerializer < BasicPostSerializer
def mentioned_users
if @topic_view && (mentions = @topic_view.mentions[object.id])
return mentions
.map { |username| @topic_view.mentioned_users[username] }
.compact
.map { |user| BasicUserWithStatusSerializer.new(user, root: false) }
users = mentions
.map { |username| @topic_view.mentioned_users[username] }
.compact
else
users = User.where(username: object.mentions)
end
[]
users.map { |user| BasicUserWithStatusSerializer.new(user, root: false) }
end
private