Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/controllers/artists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ class ArtistsController < ApplicationController
def show
artist = Artist.find(params[:id])
albums = selected_albums(artist.albums, params[:album_type]).with_attached_cover.preload(:artist)
tracks = artist.tracks.popularity_ordered.limit(5)
tracks = artist.tracks.popularity_ordered.limit(5 * (params[:tracks_page].to_i + 1))

if turbo_frame_request?
render partial: "discography", locals: {artist:, albums:}
if params[:tracks_page].present?
render partial: "tracks", locals: {artist:, tracks:}
else
render partial: "discography", locals: {artist:, albums:}
end
else
render action: :show, locals: {artist:, albums:, tracks:}
end
Expand Down
15 changes: 15 additions & 0 deletions app/views/artists/_tracks.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%# locals: (artist:, tracks:, page: params[:tracks_page]) -%>
<%= turbo_frame_tag dom_id(artist, :tracks), target: "_top" do %>
<ul class="tracks mt-2">
<%= render tracks, enqueueble: true %>
</ul>

<% if page.blank? %>
<li class="track">
<span class="track--number"></span>
<%= link_to "Load more", artist_path(tracks_page: 1),
class: "text-secondary hover:text-primary transition-colors",
data: {"turbo-frame" => "_self", "turbo-action" => "advance"} %>
</li>
<% end %>
<% end %>
8 changes: 1 addition & 7 deletions app/views/artists/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
<hr class="my-4">

<h2 class="mt-4 text-header-2">Popular</h2>
<ul class="tracks mt-2">
<%= render tracks, enqueueble: true %>
<li class="track">
<span class="track--number"></span>
<a href="#" class="text-secondary hover:text-primary transition-colors">Load more</a>
</li>
</ul>
<%= render partial: "tracks", locals: {artist:, tracks:} %>

<hr class="my-4"/>

Expand Down