[deploy] Fix current_user cache issue in comments (#10609)

This commit is contained in:
Ben Halpern 2020-10-05 10:52:12 -04:00 committed by GitHub
parent 6b125dc4b2
commit c0d5486023
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -13,6 +13,12 @@ function initializeUserProfileContent(user) {
document.getElementById('sidebar-profile').href = '/' + user.username;
}
function initializeProfileImage(user) {
if (!document.getElementById('comment-primary-user-profile--avatar')) return;
document.getElementById('comment-primary-user-profile--avatar').src =
user.profile_image_90;
}
function initializeUserSidebar(user) {
if (!document.getElementById('sidebar-nav')) return;
initializeUserProfileContent(user);
@ -116,6 +122,7 @@ function initializeBaseUserData() {
setCurrentUserToNavBar(user);
initializeUserSidebar(user);
initializeProfileImage(user);
addRelevantButtonsToArticle(user);
addRelevantButtonsToComments(user);
}

View file

@ -29,11 +29,7 @@
<% end %>
<span class="crayons-avatar crayons-avatar--l mr-2 shrink-0">
<% if user_signed_in? %>
<img src="<%= Images::Profile.call(current_user.profile_image_url, length: 50) %>" width="32" height="32" alt="pic" class="crayons-avatar__image">
<% else %>
<img src="<%= image_path("android-icon-128x128.png") %>" width="32" height="32" alt="pic" class="crayons-avatar__image">
<% end %>
<img src="<%= SiteConfig.logo_png %>" width="32" height="32" alt="pic" class="crayons-avatar__image" id="comment-primary-user-profile--avatar">
</span>
<div class="comment-form__inner">
<div class="comment-form__field">