feat(quick-3): wire playlist context menu for batch delete of selected playlists
- Update handlePlaylistContextMenu to respect multi-selection on right-click - Make onPlaylistContextAction async with batch delete support - Show 'Delete N Playlists' in context menu when multiple playlists selected - Hide 'Rename' option when multiple playlists are selected - Clear playlist selection after any context action completes
This commit is contained in:
@@ -1659,6 +1659,14 @@ export class PlaylistView
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
this.ctxMenu.close();
|
this.ctxMenu.close();
|
||||||
|
|
||||||
|
// If the right-clicked playlist is NOT in the current
|
||||||
|
// multi-selection, replace the selection with just that one.
|
||||||
|
if (!this.selectedPlaylists.has(index)) {
|
||||||
|
this.selectedPlaylists = new Set([index]);
|
||||||
|
this.lastSelectedPlaylistIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
this.playlistContextMenuIndex = index;
|
this.playlistContextMenuIndex = index;
|
||||||
this.playlistContextMenuOpen = true;
|
this.playlistContextMenuOpen = true;
|
||||||
|
|
||||||
@@ -1696,7 +1704,7 @@ export class PlaylistView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private onPlaylistContextAction(
|
private async onPlaylistContextAction(
|
||||||
action: string,
|
action: string,
|
||||||
) {
|
) {
|
||||||
const index =
|
const index =
|
||||||
@@ -1723,13 +1731,32 @@ export class PlaylistView
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete': {
|
||||||
void this.handleDeletePlaylist(
|
if (this.selectedPlaylists.size > 1) {
|
||||||
entry.summary.ID,
|
const ids = [...this.selectedPlaylists]
|
||||||
);
|
.map(i => this.entries[i])
|
||||||
|
.filter((e): e is PlaylistEntry => e !== undefined)
|
||||||
|
.map(e => e.summary.ID);
|
||||||
|
|
||||||
|
for (const id of ids) {
|
||||||
|
await DeletePlaylist(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selectedPlaylists = new Set();
|
||||||
|
this.lastSelectedPlaylistIndex = null;
|
||||||
|
await this.refreshPlaylists();
|
||||||
|
} else {
|
||||||
|
await this.handleDeletePlaylist(
|
||||||
|
entry.summary.ID,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.selectedPlaylists = new Set();
|
||||||
|
this.lastSelectedPlaylistIndex = null;
|
||||||
this.closePlaylistContextMenu();
|
this.closePlaylistContextMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2311,21 +2338,25 @@ export class PlaylistView
|
|||||||
<div
|
<div
|
||||||
class="context-menu-panel"
|
class="context-menu-panel"
|
||||||
>
|
>
|
||||||
|
${this.selectedPlaylists.size <= 1
|
||||||
|
? html`
|
||||||
|
<wa-dropdown-item
|
||||||
|
@click=${() =>
|
||||||
|
void this.onPlaylistContextAction(
|
||||||
|
'rename',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<wa-icon
|
||||||
|
slot="icon"
|
||||||
|
name="pen"
|
||||||
|
></wa-icon>
|
||||||
|
Rename
|
||||||
|
</wa-dropdown-item>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
<wa-dropdown-item
|
<wa-dropdown-item
|
||||||
@click=${() =>
|
@click=${() =>
|
||||||
this.onPlaylistContextAction(
|
void this.onPlaylistContextAction(
|
||||||
'rename',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<wa-icon
|
|
||||||
slot="icon"
|
|
||||||
name="pen"
|
|
||||||
></wa-icon>
|
|
||||||
Rename
|
|
||||||
</wa-dropdown-item>
|
|
||||||
<wa-dropdown-item
|
|
||||||
@click=${() =>
|
|
||||||
this.onPlaylistContextAction(
|
|
||||||
'delete',
|
'delete',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -2333,7 +2364,9 @@ export class PlaylistView
|
|||||||
slot="icon"
|
slot="icon"
|
||||||
name="trash"
|
name="trash"
|
||||||
></wa-icon>
|
></wa-icon>
|
||||||
Delete Playlist
|
${this.selectedPlaylists.size > 1
|
||||||
|
? `Delete ${this.selectedPlaylists.size} Playlists`
|
||||||
|
: 'Delete Playlist'}
|
||||||
</wa-dropdown-item>
|
</wa-dropdown-item>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|||||||
Reference in New Issue
Block a user