MM-18356: Adds ability to paginate channel search. (#12830)

* MM-18356: Adds ability to paginate channel search.

* MM-18356: Minor refactor.

* MM-18356: Adds doc.

* MM-18356: Fixes doc.

* MM-18356: Some commentary, adds the total count to non-paginated responses, and removes a stray fmt.

* MM-18356: Fixes shadowed variable.

* MM-18356: Removes paginate field and API parameter.

* MM-18356: Adds method to check if channel search is a paginated request.

* MM-18356: Vet fix.
Этот коммит содержится в:
Martin Kraft
2019-11-19 11:38:49 -05:00
коммит произвёл GitHub
родитель 608a137d2b
Коммит 0212845385
11 изменённых файлов: 141 добавлений и 37 удалений

Просмотреть файл

@@ -1870,7 +1870,8 @@ func (a *App) AutocompleteChannelsForSearch(teamId string, userId string, term s
return a.Srv.Store.Channel().AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted)
}
func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError) {
// SearchAllChannels returns a list of channels, the total count of the results of the search (if the paginate search option is true), and an error.
func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, *model.AppError) {
opts.IncludeDeleted = *a.Config().TeamSettings.ExperimentalViewArchivedChannels && opts.IncludeDeleted
if opts.ExcludeDefaultChannels {
opts.ExcludeChannelNames = a.DefaultChannelNames()
@@ -1879,6 +1880,8 @@ func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*mod
ExcludeChannelNames: opts.ExcludeChannelNames,
NotAssociatedToGroup: opts.NotAssociatedToGroup,
IncludeDeleted: opts.IncludeDeleted,
Page: opts.Page,
PerPage: opts.PerPage,
}
term = strings.TrimSpace(term)