added "default playlist"/ favorites system
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
contextMenuStyles,
|
||||
} from '@utils/context-menu-controller.js';
|
||||
import type { ContextMenuHost } from '@utils/context-menu-controller.js';
|
||||
import { FavoritesController } from '@store/controllers/favorites-controller';
|
||||
import {
|
||||
hasTrackPayload,
|
||||
getDragPayload,
|
||||
@@ -52,6 +53,7 @@ export class QueuePanel
|
||||
private queue = new QueueController(this);
|
||||
private selection = new SelectionController(this);
|
||||
private ctxMenu = new ContextMenuController(this);
|
||||
private favCtrl = new FavoritesController(this);
|
||||
|
||||
@property({ type: Boolean, reflect: true })
|
||||
open = false;
|
||||
@@ -622,6 +624,26 @@ export class QueuePanel
|
||||
this.ctxMenu.close();
|
||||
}
|
||||
|
||||
private onContextMenuFavoriteToggle() {
|
||||
const filePaths =
|
||||
this.getSelectedFilePaths();
|
||||
|
||||
if (filePaths.length === 0) return;
|
||||
|
||||
if (this.favCtrl.allFavorited(filePaths)) {
|
||||
void this.favCtrl.removeFromFavorites(
|
||||
filePaths,
|
||||
);
|
||||
} else {
|
||||
void this.favCtrl.addToFavorites(
|
||||
filePaths,
|
||||
);
|
||||
}
|
||||
|
||||
this.selection.clear();
|
||||
this.ctxMenu.close();
|
||||
}
|
||||
|
||||
private openTrackDetails(index: number) {
|
||||
const queueTrack =
|
||||
this.queue.tracks[index];
|
||||
@@ -1330,6 +1352,18 @@ export class QueuePanel
|
||||
▶
|
||||
</span>
|
||||
</wa-dropdown-item>
|
||||
<wa-dropdown-item
|
||||
@click=${() =>
|
||||
this.onContextMenuFavoriteToggle()}
|
||||
@mouseenter=${() =>
|
||||
this.ctxMenu.closePlaylistSubmenu()}
|
||||
>
|
||||
<wa-icon
|
||||
slot="icon"
|
||||
name=${this.favCtrl.iconName}
|
||||
></wa-icon>
|
||||
${this.favCtrl.allFavorited(this.getSelectedFilePaths()) ? `Remove from ${this.favCtrl.playlistName}` : `Add to ${this.favCtrl.playlistName}`}
|
||||
</wa-dropdown-item>
|
||||
${this.selection
|
||||
.selectionCount === 1
|
||||
? html`
|
||||
|
||||
Reference in New Issue
Block a user