mirror of
https://codeberg.org/armin/noiz.git
synced 2026-09-01 05:50:52 +02:00
fix: allow deleting the currently playing track without interrupting playback
This commit is contained in:
parent
5789e4ec9e
commit
fddbdf9a1c
1 changed files with 10 additions and 13 deletions
23
index.html
23
index.html
|
|
@ -1041,33 +1041,30 @@ function isolateTracks() {
|
|||
}
|
||||
function deleteTrack() {
|
||||
if (selectedIndices.size === 0) return;
|
||||
const sortedSel = [...selectedIndices].sort((a, b) => a - b);
|
||||
const willDeleteCurrent = selectedIndices.has(currentIndex);
|
||||
if (selectedIndices.size === tracks.length) {
|
||||
tracks.forEach(t => URL.revokeObjectURL(t.url));
|
||||
for (const idx of sortedSel) {
|
||||
if (idx !== currentIndex) URL.revokeObjectURL(tracks[idx].url);
|
||||
}
|
||||
tracks = [];
|
||||
currentIndex = -1;
|
||||
selectedIndices.clear();
|
||||
renderTracks();
|
||||
return;
|
||||
}
|
||||
const sortedSel = [...selectedIndices].sort((a, b) => a - b);
|
||||
const willDeleteCurrent = selectedIndices.has(currentIndex);
|
||||
const playingTrack = currentIndex >= 0 ? tracks[currentIndex] : null;
|
||||
for (const idx of sortedSel) URL.revokeObjectURL(tracks[idx].url);
|
||||
for (const idx of sortedSel) {
|
||||
if (idx !== currentIndex) URL.revokeObjectURL(tracks[idx].url);
|
||||
}
|
||||
for (let j = sortedSel.length - 1; j >= 0; j--) tracks.splice(sortedSel[j], 1);
|
||||
selectedIndices.clear();
|
||||
if (willDeleteCurrent) {
|
||||
if (tracks.length > 0) {
|
||||
currentIndex = Math.min(sortedSel[0], tracks.length - 1);
|
||||
playTrack(currentIndex);
|
||||
} else {
|
||||
currentIndex = -1;
|
||||
renderTracks();
|
||||
}
|
||||
currentIndex = -1;
|
||||
} else {
|
||||
const removedBefore = sortedSel.filter(idx => idx < currentIndex).length;
|
||||
currentIndex -= removedBefore;
|
||||
renderTracks();
|
||||
}
|
||||
renderTracks();
|
||||
}
|
||||
function openTagEditor() {
|
||||
let idx = -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue