fix removing songs in playlist with firebase (+ removing songs improvements)
This commit is contained in:
parent
5cdfc55e9b
commit
d245c60a05
2 changed files with 4 additions and 2 deletions
|
|
@ -537,13 +537,15 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.target.closest('.remove-from-playlist-btn')) {
|
if (e.target.closest('.remove-from-playlist-btn')) {
|
||||||
|
e.stopPropagation();
|
||||||
const btn = e.target.closest('.remove-from-playlist-btn');
|
const btn = e.target.closest('.remove-from-playlist-btn');
|
||||||
const index = parseInt(btn.dataset.trackIndex);
|
const index = parseInt(btn.dataset.trackIndex);
|
||||||
const playlistId = window.location.hash.split('/')[1];
|
const playlistId = window.location.hash.split('/')[1];
|
||||||
db.getPlaylist(playlistId).then(async (playlist) => {
|
db.getPlaylist(playlistId).then(async (playlist) => {
|
||||||
if (playlist && playlist.tracks[index]) {
|
if (playlist && playlist.tracks[index]) {
|
||||||
const trackId = playlist.tracks[index].id;
|
const trackId = playlist.tracks[index].id;
|
||||||
await db.removeTrackFromPlaylist(playlistId, trackId);
|
const updatedPlaylist = await db.removeTrackFromPlaylist(playlistId, trackId);
|
||||||
|
syncManager.syncUserPlaylist(updatedPlaylist, 'update');
|
||||||
ui.renderPlaylistPage(playlistId);
|
ui.renderPlaylistPage(playlistId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -577,7 +577,7 @@ export function initializeTrackInteractions(player, api, mainContent, contextMen
|
||||||
}
|
}
|
||||||
|
|
||||||
const trackItem = e.target.closest('.track-item');
|
const trackItem = e.target.closest('.track-item');
|
||||||
if (trackItem && !trackItem.dataset.queueIndex) {
|
if (trackItem && !trackItem.dataset.queueIndex && !e.target.closest('.remove-from-playlist-btn')) {
|
||||||
const parentList = trackItem.closest('.track-list');
|
const parentList = trackItem.closest('.track-list');
|
||||||
const allTrackElements = Array.from(parentList.querySelectorAll('.track-item'));
|
const allTrackElements = Array.from(parentList.querySelectorAll('.track-item'));
|
||||||
const trackList = allTrackElements.map(el => trackDataStore.get(el)).filter(Boolean);
|
const trackList = allTrackElements.map(el => trackDataStore.get(el)).filter(Boolean);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue