mirror of
https://codeberg.org/armin/noiz.git
synced 2026-09-01 14:00:54 +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() {
|
function deleteTrack() {
|
||||||
if (selectedIndices.size === 0) return;
|
if (selectedIndices.size === 0) return;
|
||||||
|
const sortedSel = [...selectedIndices].sort((a, b) => a - b);
|
||||||
|
const willDeleteCurrent = selectedIndices.has(currentIndex);
|
||||||
if (selectedIndices.size === tracks.length) {
|
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 = [];
|
tracks = [];
|
||||||
currentIndex = -1;
|
currentIndex = -1;
|
||||||
selectedIndices.clear();
|
selectedIndices.clear();
|
||||||
renderTracks();
|
renderTracks();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sortedSel = [...selectedIndices].sort((a, b) => a - b);
|
for (const idx of sortedSel) {
|
||||||
const willDeleteCurrent = selectedIndices.has(currentIndex);
|
if (idx !== currentIndex) URL.revokeObjectURL(tracks[idx].url);
|
||||||
const playingTrack = currentIndex >= 0 ? tracks[currentIndex] : null;
|
}
|
||||||
for (const idx of sortedSel) URL.revokeObjectURL(tracks[idx].url);
|
|
||||||
for (let j = sortedSel.length - 1; j >= 0; j--) tracks.splice(sortedSel[j], 1);
|
for (let j = sortedSel.length - 1; j >= 0; j--) tracks.splice(sortedSel[j], 1);
|
||||||
selectedIndices.clear();
|
selectedIndices.clear();
|
||||||
if (willDeleteCurrent) {
|
if (willDeleteCurrent) {
|
||||||
if (tracks.length > 0) {
|
currentIndex = -1;
|
||||||
currentIndex = Math.min(sortedSel[0], tracks.length - 1);
|
|
||||||
playTrack(currentIndex);
|
|
||||||
} else {
|
|
||||||
currentIndex = -1;
|
|
||||||
renderTracks();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const removedBefore = sortedSel.filter(idx => idx < currentIndex).length;
|
const removedBefore = sortedSel.filter(idx => idx < currentIndex).length;
|
||||||
currentIndex -= removedBefore;
|
currentIndex -= removedBefore;
|
||||||
renderTracks();
|
|
||||||
}
|
}
|
||||||
|
renderTracks();
|
||||||
}
|
}
|
||||||
function openTagEditor() {
|
function openTagEditor() {
|
||||||
let idx = -1;
|
let idx = -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue