mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 11:34:36 +08:00
If a search parameter is present (filter.q), send requests to the search endpoint instead of the filter endpoint
This commit is contained in:
parent
0172008693
commit
87d2f3d246
|
@ -83,7 +83,7 @@ export default class Store {
|
|||
*/
|
||||
find(type, id, query = {}, options = {}) {
|
||||
let params = query;
|
||||
let url = app.forum.attribute('apiUrl') + '/' + type;
|
||||
let url = app.forum.attribute('apiUrl') + (query.search ? '/search/' : '/') + type;
|
||||
|
||||
if (id instanceof Array) {
|
||||
url += '?filter[id]=' + id.join(',');
|
||||
|
|
|
@ -24,7 +24,7 @@ export default class DiscussionsSearchSource {
|
|||
include: 'mostRelevantPost',
|
||||
};
|
||||
|
||||
return app.store.find('discussions', params).then((results) => (this.results[query] = results));
|
||||
return app.store.find('discussions', params, { search: query }).then((results) => (this.results[query] = results));
|
||||
}
|
||||
|
||||
view(query) {
|
||||
|
|
|
@ -16,10 +16,14 @@ export default class UsersSearchResults {
|
|||
|
||||
search(query) {
|
||||
return app.store
|
||||
.find('users', {
|
||||
filter: { q: query },
|
||||
page: { limit: 5 },
|
||||
})
|
||||
.find(
|
||||
'users',
|
||||
{
|
||||
filter: { q: query },
|
||||
page: { limit: 5 },
|
||||
},
|
||||
{ search: query }
|
||||
)
|
||||
.then((results) => {
|
||||
this.results[query] = results;
|
||||
m.redraw();
|
||||
|
|
|
@ -119,7 +119,7 @@ export default class DiscussionListState {
|
|||
params.page = { offset };
|
||||
params.include = params.include.join(',');
|
||||
|
||||
return this.app.store.find('discussions', params);
|
||||
return this.app.store.find('discussions', params, { search: params.filter.q });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace Flarum\Forum\Content;
|
|||
|
||||
use Flarum\Api\Client;
|
||||
use Flarum\Api\Controller\ListDiscussionsController;
|
||||
use Flarum\Api\Controller\SearchDiscussionsController;
|
||||
use Flarum\Frontend\Document;
|
||||
use Flarum\Http\UrlGenerator;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
|
@ -114,6 +115,6 @@ class Index
|
|||
*/
|
||||
private function getApiDocument(User $actor, array $params)
|
||||
{
|
||||
return json_decode($this->api->send(ListDiscussionsController::class, $actor, $params)->getBody());
|
||||
return json_decode($this->api->send(($params['filter']['q'] ? SearchDiscussionsController::class : ListDiscussionsController::class), $actor, $params)->getBody());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user