favorites: remove is_favorited attribute from post API.

* Remove the data-is-favorited attribute from post thumbnails.
* Remove the is_favorited attribute from the /posts.json API.
* Remove the fav_string attribute from the /posts.json API (only visible
  to moderators).
* Change `Post#favorited_by?` to not use the fav_string.

Further addresses #4652 by eliminating the last places where fav_string
was used.
This commit is contained in:
evazion
2021-01-03 19:53:11 -06:00
parent 98ee6c31c1
commit de16d31135
7 changed files with 9 additions and 16 deletions

View File

@@ -38,11 +38,7 @@
<%= link_to recommended_posts_path(search: { post_id: post.id }), class: "more-recommended-posts", "data-post-id": post.id do %>
<%= post.fav_count %>
<% if post.favorited_by?(CurrentUser.id) %>
<i class="fas fa-heart fa-xs"></i>
<% else %>
<i class="far fa-heart fa-xs"></i>
<% end %>
<i class="far fa-heart fa-xs"></i>
<br>more »
<% end %>

View File

@@ -23,10 +23,10 @@
<% if policy(Favorite).create? %>
<li id="post-option-add-to-favorites">
<%= link_to "Favorite", favorites_path(post_id: post.id), remote: true, method: :post, id: "add-to-favorites", "data-shortcut": "f", style: ("display: none;" if @post.is_favorited?) %>
<%= link_to "Favorite", favorites_path(post_id: post.id), remote: true, method: :post, id: "add-to-favorites", "data-shortcut": "f", style: ("display: none;" if @post.favorited_by?(CurrentUser.user)) %>
</li>
<li id="post-option-remove-from-favorites">
<%= link_to "Unfavorite", favorite_path(post), remote: true, method: :delete, id: "remove-from-favorites", "data-shortcut": "shift+f", "data-shortcut-when": ":visible", style: ("display: none;" if !@post.is_favorited?) %>
<%= link_to "Unfavorite", favorite_path(post), remote: true, method: :delete, id: "remove-from-favorites", "data-shortcut": "shift+f", "data-shortcut-when": ":visible", style: ("display: none;" if !@post.favorited_by?(CurrentUser.user)) %>
</li>
<% end %>
<% if policy(post).update? %>