Skip to content

Commit

Permalink
Ensure articles showcased in the profile can be favorited
Browse files Browse the repository at this point in the history
  • Loading branch information
ellmetha committed Oct 19, 2023
1 parent d05fbd1 commit e1f8079
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/apps/profiles/templates/profiles/profile_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h4>{{ profile.username }}</h4>
{% assign articles_query_param = "&articles=favorited" %}
{% endif %}

{% include "blogging/partials/article_feed.html" with additional_page_params = articles_query_param %}
{% include "partials/article_feed.html" with additional_page_params = articles_query_param %}
</div>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/assets/js/controllers/profiles/ProfileDetailController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import initFavoriteButtons from '../../core/initFavoriteButtons';
import initFollowButtons from '../../core/initFollowButtons';

export default {
async init() {
const profilePageDiv = document.getElementById('profile_page');
await initFollowButtons(profilePageDiv.dataset.username);
await initFavoriteButtons();
},
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% for article in articles %}
{% include "blogging/partials/article_preview.html" with article = article %}
{% include "partials/article_preview.html" with article = article %}
{% else %}
<div class="article-preview">No articles are here... yet.</div>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<span class="date">{{ article.created_at | time: "%B %-d" }}</span>
</div>
{% if request.user? %}
<button class="favorite-article-btn btn btn-sm pull-xs-right {% if article in request.user.profile.favorite_articles %}btn-primary favorited{% else %}btn-outline-primary{% endif %}">
<i class="ion-heart"></i> <span class="favorite-count">{{ article.favorited_by.size }}</span>
<button class="favorite-button favorite-article-btn btn btn-sm pull-xs-right {% if article in request.user.profile.favorite_articles %}btn-primary favorited{% else %}btn-outline-primary{% endif %}" data-article-slug="{{ article.slug }}">
<i class="ion-heart"></i> <span class="counter">{{ article.favorited_by.size }}</span>
</button>
{% endif %}
</div>
Expand Down

0 comments on commit e1f8079

Please sign in to comment.