mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
FIX: Show user filter hints when typing @
in search (#13799)
Will show the last 6 seen users as filtering suggestions when typing @ in quick search. (Previously the user suggestion required a character after the @.) This also adds a default limit of 6 to the user search query, previously the backend was returning 20 results but a maximum of 6 results was being shown anyway.
This commit is contained in:
@ -12,6 +12,7 @@ class UserSearch
|
||||
@topic_allowed_users = opts[:topic_allowed_users]
|
||||
@searching_user = opts[:searching_user]
|
||||
@include_staged_users = opts[:include_staged_users] || false
|
||||
@last_seen_users = opts[:last_seen_users] || false
|
||||
@limit = opts[:limit] || 20
|
||||
@groups = opts[:groups]
|
||||
|
||||
@ -162,6 +163,15 @@ class UserSearch
|
||||
.each { |id| users << id }
|
||||
end
|
||||
|
||||
# 5. last seen users (for search auto-suggestions)
|
||||
if @last_seen_users
|
||||
scoped_users
|
||||
.order('last_seen_at DESC NULLS LAST')
|
||||
.limit(@limit - users.size)
|
||||
.pluck(:id)
|
||||
.each { |id| users << id }
|
||||
end
|
||||
|
||||
users.to_a
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user