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='comment'>
<div class='avatar'> <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) %>'> <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> </a>
<% } %> <% } %>
</div> </div>
@ -14,13 +14,13 @@
<div class='body'> <div class='body'>
<header><!-- <header><!--
--><span class='nickname'><!-- --><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) %>'><!-- --><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><!-- --></a><!--
--><% } %><!-- --><% } %><!--
--></span><!-- --></span><!--

View file

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