diff --git a/app/javascript/controllers/audio_player_controller.js b/app/javascript/controllers/audio_player_controller.js index bb30c04..38d0fbd 100644 --- a/app/javascript/controllers/audio_player_controller.js +++ b/app/javascript/controllers/audio_player_controller.js @@ -258,5 +258,18 @@ export default class extends Controller { ? playlist[playlist.length - 1] : playlist[currentTrackIndex - 1]; } + + removeSong(e) { + e.preventDefault() + const trackIdToRemove = e.currentTarget.dataset.value + const { playlist } = store.getState(); + + document.querySelector(`#sidebar-track-${trackIdToRemove}`).remove() + + // Filter out the track ID to remove + const newPlaylist = playlist.filter(trackId => trackId !== trackIdToRemove); + + store.setState({ playlist: newPlaylist }); + } } diff --git a/app/javascript/controllers/track_detector_controller.js b/app/javascript/controllers/track_detector_controller.js index d00e1eb..a478232 100644 --- a/app/javascript/controllers/track_detector_controller.js +++ b/app/javascript/controllers/track_detector_controller.js @@ -1,4 +1,5 @@ import { Controller } from "@hotwired/stimulus" +import { get } from '@rails/request.js' // it locates and append tracks to the playlist sidebar export default class extends Controller { @@ -14,4 +15,16 @@ export default class extends Controller { const playlist = new Set([...store.getState().playlist, ...newIds]) store.setState({ playlist: Array.from(playlist) }) } + + async addGroup(e) { + const newIds = this.trackTargets.map((track) => track.dataset.trackId) + const playlist = new Set([...store.getState().playlist, ...newIds]) + store.setState({ playlist: Array.from(playlist) }) + + console.log("Added group of tracks:", Array.from(newIds)) + + await get(e.currentTarget.dataset.trackInitPath, { + responseKind: "turbo-stream", + }) + } } \ No newline at end of file diff --git a/app/models/track.rb b/app/models/track.rb index ef47ee4..8656f1d 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -342,6 +342,10 @@ def self.get_tracks_by_tag(tag) includes(:user).where("? = ANY (tags)", tag) end + def duration + "xx;xx" + end + def podcast_summarizer file_path = ActiveStorage::Blob.service.path_for(mp3_audio.key) summarizer = AudioSummarizer.new(file_path) diff --git a/app/views/player/_sidebar.erb b/app/views/player/_sidebar.erb index b75cc4a..914db2d 100644 --- a/app/views/player/_sidebar.erb +++ b/app/views/player/_sidebar.erb @@ -57,7 +57,7 @@ class="-my-5 divide-y divide-gray-200 dark:divide-gray-800 h-full" > <%= turbo_frame_tag "player-sidebar-tracks-list" do %> - oliii + .... <% end %> diff --git a/app/views/player/_track.erb b/app/views/player/_track.erb index abc2486..d00d55c 100644 --- a/app/views/player/_track.erb +++ b/app/views/player/_track.erb @@ -18,7 +18,7 @@