FIX: User page broke when the user had no stats

This commit is contained in:
Robin Ward 2013-07-12 15:59:35 -04:00
parent a43ed88699
commit 35128c212b

View File

@ -252,10 +252,13 @@ Discourse.User = Discourse.Model.extend({
return PreloadStore.getAndRemove("user_" + user.get('username'), function() {
return Discourse.ajax("/users/" + user.get('username') + '.json');
}).then(function (json) {
json.user.stats = Discourse.User.groupStats(_.map(json.user.stats,function(s) {
if (s.count) s.count = parseInt(s.count, 10);
return Discourse.UserActionStat.create(s);
}));
if (!Em.isEmpty(json.user.stats)) {
json.user.stats = Discourse.User.groupStats(_.map(json.user.stats,function(s) {
if (s.count) s.count = parseInt(s.count, 10);
return Discourse.UserActionStat.create(s);
}));
}
if (json.user.invited_by) {
json.user.invited_by = Discourse.User.create(json.user.invited_by);