Skip to content

Commit

Permalink
Fix empty playlist page
Browse files Browse the repository at this point in the history
  • Loading branch information
jcraigk committed Oct 21, 2023
1 parent 89a998b commit a57972b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/playlists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def active

track_ids = session['playlist']['tracks']
tracks_by_id = Track.where(id: track_ids).includes(:show, track_tags: :tag).index_by(&:id)
@tracks = track_ids.map { |id| tracks_by_id[id] }
@tracks = track_ids&.map { |id| tracks_by_id[id] } || []
@tracks_likes = user_likes_for_tracks(@tracks)
@duration = @tracks&.sum(&:duration)
@stored = Playlist.where(user: current_user).order(name: :asc) if current_user
Expand Down
8 changes: 4 additions & 4 deletions app/views/playlists/active.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#playlist_data data-id=session['playlist']['id'] data-name=session['playlist']['name'] data-slug=session['playlist']['slug'] data-user-id=session['playlist']['user_id'] data-username=session['playlist']['username']

#title_box
h1.playlist_title = session['playlist']['id'].positive? ? session['playlist'][:name] : '(Untitled Playlist)'
- if session['playlist']['id'].positive?
h1.playlist_title = session['playlist']['id']&.positive? ? session['playlist'][:name] : '(Untitled Playlist)'
- if session['playlist']['id']&.positive?
h3 Author: #{session['playlist']['username']}
h3#active_playlist_tracks_label Tracks: #{@tracks.size}
h3#active_playlist_duration_label Length: #{duration_readable(@duration, 'letters')}
Expand All @@ -22,7 +22,7 @@
br

- if user_signed_in?
- if session['playlist']['id'].positive? && session['playlist']['user_id'] != current_user.id
- if session['playlist']['id']&.positive? && session['playlist']['user_id'] != current_user.id
button#duplicate_playlist_btn.btn type='button'
i.glyphicon.glyphicon-file
| DUPLICATE
Expand All @@ -34,7 +34,7 @@
| SAVE
br

- if session['playlist']['id'].positive?
- if session['playlist']['id']&.positive?
- if current_user.id == session['playlist']['user_id']
button#delete_playlist_btn.btn type='button'
i.glyphicon.glyphicon-remove
Expand Down

0 comments on commit a57972b

Please sign in to comment.