Quick notifications fix (#1179)

This commit is contained in:
Ben Halpern 2018-11-22 11:40:05 -05:00 committed by GitHub
parent eccee11106
commit 3b94e1d1a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 19 deletions

View file

@ -9,10 +9,10 @@ class NotificationsController < ApplicationController
current_user
end
if params[:page]
num = 48
num = 45
notified_at_offset = Notification.find(params[:page])&.notified_at
else
num = 12
num = 10
end
if params[:filter].to_s.downcase == "posts"
@notifications = Notification.where(user_id: current_user.id, notifiable_type: "Article", action: "Published").

View file

@ -7,4 +7,5 @@
</div>
<% rescue => e %>
<% logger.error("Notifification error - #{e.message} - #{notification.id}") %>
</div>
<% end %>

View file

@ -1,21 +1,12 @@
<%# missing cache key %>
<% if notification.json_data["reaction"]["aggregated_siblings"].length == 1 %>
<% if notification.json_data["reaction"]["category"] != "readinglist" %>
<% cache "activity-profile-pic-#{notification.json_data["user"]["id"]}-#{notification.json_data["user"]["profile_image_90"]}" do %>
<a href="<%= notification.json_data["user"]["path"] %>" class="small-pic-link-wrapper">
<div class="small-pic">
<img src="<%= notification.json_data["user"]["profile_image_90"] %>" alt="link to <%= notification.json_data["user"]["username"] %> profile">
</div>
</a>
<% end %>
<% else %>
<% cache "activity-profile-pic-readinglist-icon" do %>
<a href="#" class="small-pic-link-wrapper">
<div class="small-pic">
<img src="<%= asset_path ReactionImage.new("readinglist").path %>" alt="">
</div>
</a>
<% end %>
<% siblings = notification.json_data["reaction"]["aggregated_siblings"].select{|n| n["created_at"] > 24.hours.ago } %>
<% if siblings.length == 0 %>
<% cache "activity-profile-pic-#{notification.json_data["user"]["id"]}-#{notification.json_data["user"]["profile_image_90"]}" do %>
<a href="<%= notification.json_data["user"]["path"] %>" class="small-pic-link-wrapper">
<div class="small-pic">
<img src="<%= notification.json_data["user"]["profile_image_90"] %>" alt="link to <%= notification.json_data["user"]["username"] %> profile">
</div>
</a>
<% end %>
<div class="content notification-content reaction-content">
<a href="<%= notification.json_data["user"]["path"] %>"><strong><%= notification.json_data["user"]["name"] %></strong></a> reacted to