Check for commentable in notifications (#121)

This commit is contained in:
Ben Halpern 2018-03-22 13:38:23 -04:00 committed by GitHub
parent cd8f63ba2c
commit 673939fd72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,46 +1,48 @@
<% cache "comment-box-#{@last_user_reaction}-#{@last_user_comment}-#{activity['object'].updated_at}-#{activity['object'].id}" do %>
<div class="comment-text">
<a href="<%= activity['object'].path %>" class="comment-link-wrapper"></a>
<%= activity['object'].processed_html.html_safe %>
</div>
<div class="comment-actions">
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(activity['object'], current_user, "like") ? "reacted" : "" %>" data-reactable-id="<%=activity['object'].id%>" data-category="like" data-reactable-type="Comment" title="heart">
<%= image_tag "favorite-heart-outline-button.svg" %>
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-heart.png") %>"/>
</button>
<% if context == "moderation" && current_user.has_role?(:trusted) %>
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(activity['object'], current_user, "thumbsdown") ? "reacted" : "" %>" data-reactable-id="<%=activity['object'].id%>" data-category="thumbsdown" data-reactable-type="Comment">
<%= image_tag "emoji/emoji-one-thumbs-down-gray.png" %>
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-thumbs-down.png") %>"/>
</button>
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(activity['object'], current_user, "vomit") ? "reacted" : "" %>" data-reactable-id="<%= activity['object'].id %>" data-category="vomit" data-reactable-type="Comment">
<%= image_tag "emoji/emoji-one-nausea-face-gray.png" %>
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-nausea-face.png") %>"/>
</button>
<% end %>
<% reply = activity['object'].children.where(:user_id => current_user.id).select(:id,:user_id).first %>
<% if reply %>
<a class="toggle-reply-form already-replied-link" href="<%= reply.path %>">
Replied
</a>
<% else %>
<a class="toggle-reply-form" data-reactable-id="<%=activity['object'].id%>" href="#<%= activity['object'].path %>">
Reply
</a>
<% end %>
</div>
<% @comment = Comment.new %>
<%= form_for(@comment, authenticity_token: false, html: {id: "comment-form-for-#{activity['object'].id}", onsubmit: "handleCommentSubmit.bind(this)(event)"}) do |f| %>
<input type="hidden" name="authenticity_token" value="NOTHING" id="new_comment_authenticity_token">
<%= f.hidden_field :commentable_id, value: activity['object'].commentable.id %>
<%= f.hidden_field :commentable_type, value: activity['object'].commentable.class.name %>
<% if activity['object'].commentable %>
<div class="comment-text">
<a href="<%= activity['object'].path %>" class="comment-link-wrapper"></a>
<%= activity['object'].processed_html.html_safe %>
</div>
<div class="comment-actions">
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(activity['object'], current_user, "like") ? "reacted" : "" %>" data-reactable-id="<%=activity['object'].id%>" data-category="like" data-reactable-type="Comment" title="heart">
<%= image_tag "favorite-heart-outline-button.svg" %>
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-heart.png") %>"/>
</button>
<% if context == "moderation" && current_user.has_role?(:trusted) %>
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(activity['object'], current_user, "thumbsdown") ? "reacted" : "" %>" data-reactable-id="<%=activity['object'].id%>" data-category="thumbsdown" data-reactable-type="Comment">
<%= image_tag "emoji/emoji-one-thumbs-down-gray.png" %>
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-thumbs-down.png") %>"/>
</button>
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(activity['object'], current_user, "vomit") ? "reacted" : "" %>" data-reactable-id="<%= activity['object'].id %>" data-category="vomit" data-reactable-type="Comment">
<%= image_tag "emoji/emoji-one-nausea-face-gray.png" %>
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-nausea-face.png") %>"/>
</button>
<% end %>
<% reply = activity['object'].children.where(:user_id => current_user.id).select(:id,:user_id).first %>
<% if reply %>
<a class="toggle-reply-form already-replied-link" href="<%= reply.path %>">
Replied
</a>
<% else %>
<a class="toggle-reply-form" data-reactable-id="<%=activity['object'].id%>" href="#<%= activity['object'].path %>">
Reply
</a>
<% end %>
</div>
<% @comment = Comment.new %>
<%= form_for(@comment, authenticity_token: false, html: {id: "comment-form-for-#{activity['object'].id}", onsubmit: "handleCommentSubmit.bind(this)(event)"}) do |f| %>
<input type="hidden" name="authenticity_token" value="NOTHING" id="new_comment_authenticity_token">
<%= f.hidden_field :commentable_id, value: activity['object'].commentable.id %>
<%= f.hidden_field :commentable_type, value: activity['object'].commentable.class.name %>
<%= f.hidden_field :parent_id, value: activity['object'].id %>
<div class="field" id="textarea-wrapper">
<%= f.text_area :body_markdown, id: "comment-textarea-for-#{activity['object'].id}" %>
</div>
<div class="actions" id="submit-wrapper">
<%= f.submit "SUBMIT", id: "submit-button", onclick:"validateField(event)" %>
</div>
<%= f.hidden_field :parent_id, value: activity['object'].id %>
<div class="field" id="textarea-wrapper">
<%= f.text_area :body_markdown, id: "comment-textarea-for-#{activity['object'].id}" %>
</div>
<div class="actions" id="submit-wrapper">
<%= f.submit "SUBMIT", id: "submit-button", onclick:"validateField(event)" %>
</div>
<% end %>
<% end %>
<% end %>