client/general: fix support for deleted users

This commit is contained in:
rr- 2016-08-02 11:58:56 +02:00
parent 688740afa9
commit 67f803a2f2
2 changed files with 9 additions and 8 deletions

View File

@ -1,12 +1,12 @@
<div class='comment'>
<div class='avatar'>
<% if (ctx.comment.user.name && ctx.canViewUsers) { %>
<% if (ctx.comment.user && ctx.comment.user.name && ctx.canViewUsers) { %>
<a href='/user/<%- encodeURIComponent(ctx.comment.user.name) %>'>
<% } %>
<%= ctx.makeThumbnail(ctx.comment.user.avatarUrl) %>
<%= ctx.makeThumbnail(ctx.comment.user ? ctx.comment.user.avatarUrl : null) %>
<% if (ctx.comment.user.name && ctx.canViewUsers) { %>
<% if (ctx.comment.user && ctx.comment.user.name && ctx.canViewUsers) { %>
</a>
<% } %>
</div>
@ -14,13 +14,13 @@
<div class='body'>
<header><!--
--><span class='nickname'><!--
--><% if (ctx.comment.user.name && ctx.canViewUsers) { %><!--
--><% if (ctx.comment.user && ctx.comment.user.name && ctx.canViewUsers) { %><!--
--><a href='/user/<%- encodeURIComponent(ctx.comment.user.name) %>'><!--
--><% } %><!--
--><%- ctx.comment.user.name %><!--
--><%- ctx.comment.user ? ctx.comment.user.name : 'Deleted user' %><!--
--><% if (ctx.comment.user.name && ctx.canViewUsers) { %><!--
--><% if (ctx.comment.user && ctx.comment.user.name && ctx.canViewUsers) { %><!--
--></a><!--
--><% } %><!--
--></span><!--

View File

@ -189,8 +189,9 @@ function makeTagLink(name) {
}
function makeUserLink(user) {
const text = makeThumbnail(user.avatarUrl) + user.name;
const link = api.hasPrivilege('users:view') ?
let text = makeThumbnail(user ? user.avatarUrl : null);
text += user && user.name ? user.name : 'Anonymous';
const link = user && api.hasPrivilege('users:view') ?
makeNonVoidElement(
'a', {'href': '/user/' + encodeURIComponent(user.name)}, text) :
text;