FIX: Limits for PM and group header search (#16887)

When searching for PMs or PMs in a group inbox, results in the header search were not being limited to 5 with a "More" link to the full page search. This PR fixes that.

It also simplifies the logic and updates the search API docs to include recently added `in:messages` and `group_messages:groupname` options.
This commit is contained in:
Penar Musaraj
2022-05-24 11:31:24 -04:00
committed by GitHub
parent 0403a8633b
commit 8222810099
5 changed files with 49 additions and 11 deletions

View File

@@ -31,7 +31,7 @@ class Search
BLURB_LENGTH = 200
def initialize(type_filter:, term:, search_context:, blurb_length: nil, blurb_term: nil)
def initialize(type_filter:, term:, search_context:, blurb_length: nil, blurb_term: nil, is_header_search: false)
@type_filter = type_filter
@term = term
@blurb_term = blurb_term || term
@@ -43,6 +43,7 @@ class Search
@tags = []
@groups = []
@error = nil
@is_header_search = is_header_search
end
def error=(error)
@@ -85,10 +86,9 @@ class Search
def add(object)
type = object.class.to_s.downcase.pluralize
if @type_filter.present? && public_send(type).length == Search.per_filter
if !@is_header_search && public_send(type).length == Search.per_filter
@more_full_page_results = true
elsif !@type_filter.present? && public_send(type).length == Search.per_facet
elsif @is_header_search && public_send(type).length == Search.per_facet
instance_variable_set("@more_#{type}".to_sym, true)
else
(self.public_send(type)) << object