Early return from org follow check (#20761)

* Early return from org follow check

* Adjust podcast follow button

* Move early return to later
This commit is contained in:
Ben Halpern 2024-03-11 18:24:19 -04:00 committed by GitHub
parent 501b900108
commit f4b94ce7f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 3 deletions

View file

@ -416,7 +416,6 @@ function initializeNonUserFollowButtons() {
document.body.getAttribute('data-user-status') === 'logged-in';
const user = userLoggedIn ? userData() : null;
const followedTags = user
? JSON.parse(user.followed_tags).map((tag) => tag.id)
: [];
@ -428,6 +427,9 @@ function initializeNonUserFollowButtons() {
const buttonInfo = JSON.parse(info);
const { className, name } = buttonInfo;
addAriaLabelToButton({ button, followType: className, followName: name });
if (user === null) {
return; // No need to fetch the status if the user is logged out
}
if (className === 'Tag' && user) {
// We don't need to make a network request to 'fetch' the status of tag buttons
button.dataset.fetched = true;

View file

@ -21,7 +21,7 @@
class="crayons-btn crayons-btn--inverted follow-action-button"
style="min-width: 100px;"
data-info='<%= DataInfo.to_json(object: @podcast) %>'>
&nbsp;
<%= t("views.podcasts.follow") %>
</button>
</p>
</div>

View file

@ -39,7 +39,7 @@
id="user-follow-butt"
class="crayons-btn follow-action-button"
data-info='<%= DataInfo.to_json(object: @podcast) %>'>
&nbsp;
<%= t("views.podcasts.follow") %>
</button>
</h2>
<% if @episode.title.size > 60 %>

View file

@ -34,3 +34,4 @@ en:
latest_episodes: Latest episodes
suggest_a_podcast: Suggest a Podcast
view_all_podcasts: View all podcasts
follow: Follow

View file

@ -34,3 +34,4 @@ fr:
latest_episodes: Épisodes Récents
suggest_a_podcast: Suggérer un podcast
view_all_podcasts: Voir tous les podcasts
follow: Follow