BUGFIX: error when find_similar_to has no response
This commit is contained in:
parent
a524194a46
commit
0bb02505b0
|
@ -318,7 +318,11 @@ Discourse.Topic.reopenClass({
|
||||||
**/
|
**/
|
||||||
findSimilarTo: function(title, body) {
|
findSimilarTo: function(title, body) {
|
||||||
return Discourse.ajax("/topics/similar_to", { data: {title: title, raw: body} }).then(function (results) {
|
return Discourse.ajax("/topics/similar_to", { data: {title: title, raw: body} }).then(function (results) {
|
||||||
return results.map(function(topic) { return Discourse.Topic.create(topic); });
|
if (Array.isArray(results)) {
|
||||||
|
return results.map(function(topic) { return Discourse.Topic.create(topic); });
|
||||||
|
} else {
|
||||||
|
return Ember.A();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue