Fix create new playlist option conflicting with pending playlist IDs
- Use CREATE_NEW_PLAYLIST (-999999) instead of -1 - Prevents conflict with negative pending playlist IDs (-1, -2, etc.) - Fixes add to playlist showing name input when selecting existing pending playlist
This commit is contained in:
1 parent
e877f6fdd9
commit
3613dd5fdb
1 file changed
+7
-4
@@ -46,6 +46,9 @@
|
|||||||
let loading = $state(false);
|
let loading = $state(false);
|
||||||
let error = $state<string | null>(null);
|
let error = $state<string | null>(null);
|
||||||
|
|
||||||
|
// Special value for "create new playlist" option (won't collide with negative pending playlist IDs)
|
||||||
|
const CREATE_NEW_PLAYLIST = -999999;
|
||||||
|
|
||||||
// Local track counts for playlists
|
// Local track counts for playlists
|
||||||
let localTrackCounts = $state<Map<number, number>>(new Map());
|
let localTrackCounts = $state<Map<number, number>>(new Map());
|
||||||
let showDeleteConfirm = $state(false);
|
let showDeleteConfirm = $state(false);
|
||||||
@@ -314,7 +317,7 @@
|
|||||||
} else if (mode === 'edit') {
|
} else if (mode === 'edit') {
|
||||||
handleUpdate();
|
handleUpdate();
|
||||||
} else if (mode === 'addTrack') {
|
} else if (mode === 'addTrack') {
|
||||||
if (selectedPlaylistId === -1) {
|
if (selectedPlaylistId === CREATE_NEW_PLAYLIST) {
|
||||||
// Create new playlist option selected
|
// Create new playlist option selected
|
||||||
handleCreateAndAdd();
|
handleCreateAndAdd();
|
||||||
} else {
|
} else {
|
||||||
@@ -375,14 +378,14 @@
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
>
|
>
|
||||||
<option value={null}>Select a playlist...</option>
|
<option value={null}>Select a playlist...</option>
|
||||||
<option value={-1}>+ Create new playlist</option>
|
<option value={CREATE_NEW_PLAYLIST}>+ Create new playlist</option>
|
||||||
{#each userPlaylists as pl (pl.id)}
|
{#each userPlaylists as pl (pl.id)}
|
||||||
<option value={pl.id}>{pl.name} ({getTotalTrackCount(pl)} tracks)</option>
|
<option value={pl.id}>{pl.name} ({getTotalTrackCount(pl)} tracks)</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if selectedPlaylistId === -1}
|
{#if selectedPlaylistId === CREATE_NEW_PLAYLIST}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Playlist name</label>
|
<label for="name">Playlist name</label>
|
||||||
<input
|
<input
|
||||||
@@ -483,7 +486,7 @@
|
|||||||
Create
|
Create
|
||||||
{:else if mode === 'edit'}
|
{:else if mode === 'edit'}
|
||||||
Save
|
Save
|
||||||
{:else if selectedPlaylistId === -1}
|
{:else if selectedPlaylistId === CREATE_NEW_PLAYLIST}
|
||||||
Create & Add
|
Create & Add
|
||||||
{:else}
|
{:else}
|
||||||
Add
|
Add
|
||||||
|
|||||||
Reference in new issue
Block a user