added "default playlist"/ favorites system
This commit is contained in:
@@ -20,6 +20,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 '@awesome.me/webawesome/dist/components/icon/icon.js';
|
||||
import '@awesome.me/webawesome/dist/components/popup/popup.js';
|
||||
@@ -61,6 +62,7 @@ export class GenresView
|
||||
private libraryCtrl = new LibraryController(this);
|
||||
private searchCtrl = new SearchController(this);
|
||||
private ctxMenu = new ContextMenuController(this);
|
||||
private favCtrl = new FavoritesController(this);
|
||||
private wheelListenerAttached = false;
|
||||
private lastSearchTerm = '';
|
||||
|
||||
@@ -873,6 +875,25 @@ export class GenresView
|
||||
this.ctxMenu.close();
|
||||
}
|
||||
|
||||
private async onContextMenuFavoriteToggle() {
|
||||
const filePaths =
|
||||
await this.getContextMenuGenreFilePaths();
|
||||
|
||||
if (filePaths.length === 0) return;
|
||||
|
||||
if (this.favCtrl.allFavorited(filePaths)) {
|
||||
void this.favCtrl.removeFromFavorites(
|
||||
filePaths,
|
||||
);
|
||||
} else {
|
||||
void this.favCtrl.addToFavorites(
|
||||
filePaths,
|
||||
);
|
||||
}
|
||||
|
||||
this.ctxMenu.close();
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* Helpers
|
||||
* ================================================================ */
|
||||
@@ -1054,6 +1075,18 @@ export class GenresView
|
||||
>▶</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.ctxMenu.playlistFilePaths) ? `Remove from ${this.favCtrl.playlistName}` : `Add to ${this.favCtrl.playlistName}`}
|
||||
</wa-dropdown-item>
|
||||
</div>
|
||||
`
|
||||
: nothing}
|
||||
|
||||
Reference in New Issue
Block a user