From 5a266ed30562c71a58278ccfa74836a97c1ea136 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Tue, 26 May 2015 18:02:04 +0930 Subject: [PATCH] Fix error when rendering deleted user --- framework/core/js/forum/src/components/event-post.js | 3 ++- framework/core/js/forum/src/initializers/routes.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/framework/core/js/forum/src/components/event-post.js b/framework/core/js/forum/src/components/event-post.js index f22852e18..0d944d60d 100644 --- a/framework/core/js/forum/src/components/event-post.js +++ b/framework/core/js/forum/src/components/event-post.js @@ -7,6 +7,7 @@ import { dasherize } from 'flarum/utils/string'; export default class EventPost extends Post { view(iconName, content, attrs) { var post = this.props.post; + var user = post.user(); attrs = attrs || {}; attrs.className = 'event-post post-'+dasherize(post.contentType())+' '+(attrs.className || ''); @@ -14,7 +15,7 @@ export default class EventPost extends Post { return super.view([ icon(iconName+' post-icon'), m('div.event-post-info', [ - m('a.post-user', {href: app.route('user', { username: post.user().username() }), config: m.route}, username(post.user())), ' ', + user ? m('a.post-user', {href: app.route.user(user), config: m.route}, username(user)) : username(user), ' ', content ]), m('div.event-post-time', humanTime(post.time())) diff --git a/framework/core/js/forum/src/initializers/routes.js b/framework/core/js/forum/src/initializers/routes.js index 0ad18b168..57f844bad 100644 --- a/framework/core/js/forum/src/initializers/routes.js +++ b/framework/core/js/forum/src/initializers/routes.js @@ -34,4 +34,10 @@ export default function(app) { near: post.number() }); }; + + app.route.user = function(user) { + return app.route('user', { + username: user.username() + }); + }; }