mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
refactor and fix bug I introduced
This commit is contained in:
parent
eca2931a63
commit
201891f51f
@ -35,20 +35,19 @@ Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, {
|
|||||||
if (results) {
|
if (results) {
|
||||||
searchController.set('noResults', results.length === 0);
|
searchController.set('noResults', results.length === 0);
|
||||||
|
|
||||||
// Make it easy to find the results by type
|
|
||||||
var results_hashed = {};
|
|
||||||
results.forEach(function(r) { results_hashed[r.type] = r });
|
|
||||||
|
|
||||||
// Default order
|
|
||||||
var order = ['topic', 'category', 'user'];
|
|
||||||
results = _(order).map(function(o) { return results_hashed[o] }).without(void 0);
|
|
||||||
|
|
||||||
var index = 0;
|
var index = 0;
|
||||||
results.forEach(function(r) {
|
results = _(['topic', 'category', 'user'])
|
||||||
_.each(r.results,function(item) {
|
.map(function(n){
|
||||||
item.index = index++;
|
return _(results).where({type: n}).first()
|
||||||
});
|
})
|
||||||
});
|
.without(undefined)
|
||||||
|
.each(function(list){
|
||||||
|
_.each(list.results, function(item){
|
||||||
|
item.index = index++;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.value();
|
||||||
|
|
||||||
searchController.set('count', index);
|
searchController.set('count', index);
|
||||||
searchController.set('content', results);
|
searchController.set('content', results);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user