Skip to content

Commit

Permalink
Fix saved playlist loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jcraigk committed Dec 2, 2023
1 parent 02503b9 commit 72455b5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
19 changes: 11 additions & 8 deletions app/controllers/playlists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ def load
end

def destroy
if current_user && params[:id] && (playlist = fetch_playlist)
if (playlist = current_user&.playlists&.find_by(id: params[:id]))
playlist.destroy
return render json: { success: true, msg: 'Playlist deleted' }
end

render json: { success: false, msg: 'Invalid delete request' }
render json: { success: false, msg: 'Invalid playlist delete request' }
end

def bookmark
Expand Down Expand Up @@ -298,15 +297,19 @@ def activate_stored(playlist)

def update_playlist(playlist)
track_ids = playlist.playlist_tracks.order(position: :asc).pluck(:track_id)
session['playlist'].merge!(
tracks: track_ids,
shuffled_tracks: track_ids.shuffle,
session['playlist'].merge!(playlist_attrs(playlist, track_ids))
end

def playlist_attrs(playlist, track_ids)
{
id: playlist.id,
name: playlist.name,
slug: playlist.slug,
user_id: playlist.user.id,
username: playlist.user.username
)
username: playlist.user.username,
tracks: track_ids,
shuffled_tracks: track_ids.shuffle
}.stringify_keys
end

def retrieve_bookmark(playlist)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def char_starts_name_or_title?(current_item, char)
end

def default_char?(current_item, _char, idx)
(params[:char].nil? && current_item.nil? && idx.zero?)
params[:char].nil? && current_item.nil? && idx.zero?
end

def global_nav_items
Expand Down Expand Up @@ -127,7 +127,7 @@ def playlists_sub_links

def years_sub_links
str = ''
ERAS.to_a.reverse.to_h.each do |_era, years|
ERAS.to_a.reverse.to_h.each_value do |years|
years.reverse.each_with_index do |year, i|
style = i + 1 == years.size ? 'margin-right: 15px' : ''
css = year == params[:slug] ? 'active' : ''
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/track_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def next_gap_link(song, date) # rubocop:disable Metrics/AbcSize, Metrics/MethodL
.where('date BETWEEN ? AND ?', date, next_show.date)
.count
text = 'Next Performance'
text = "#{tag.i(class: 'glyphicon glyphicon-forward')}  #{text}(gap: #{gap})"
text = "#{tag.i(class: 'glyphicon glyphicon-forward')}  #{text} (gap: #{gap})"
link_to(text.html_safe, "/#{next_show.date}/#{track.slug}")
end

Expand Down
4 changes: 0 additions & 4 deletions app/javascript/packs/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,15 @@ $scrubbing: #1a80f6;
border-radius: 5px;
}
.ui-dialog {
background: $gray_70;
border-radius: 5px;

.ui-dialog-titlebar {
background: $gray_80;
border: none;
color: $background_gray;
font-size: 1.5em;
line-height: 1.2em;
}
.ui-dialog-content {
font-family: 'Open Sans Condensed', sans-serif;
color: $background_gray
}
}
.tagin_project {
Expand Down

0 comments on commit 72455b5

Please sign in to comment.