FIX: topic.posters might be null or empty

This commit is contained in:
Régis Hanol 2015-11-02 11:39:23 +01:00
parent 7ced16acbf
commit d0fe4fc4b5

View file

@ -15,8 +15,12 @@ const Topic = RestModel.extend({
@computed('posters.@each')
lastPoster(posters) {
const latest = posters.filter(p => p.extras && p.extras.indexOf("latest") >= 0)[0];
return latest.user;
if (posters && posters.length > 0) {
const latest = posters.filter(p => p.extras && p.extras.indexOf("latest") >= 0)[0];
return latest.user;
} else {
return this.get("creator");
}
},
@computed('fancy_title')