feat(18-02): wire batch track-details to all 4 view context menus
- track-list: branch on selection count, resolve tracks from this.tracks - cover-grid: branch on selection count, resolve from expandedTracks - queue-panel: branch on indices count, resolve via libraryStore.getCachedTracks - playlist-details: branch on selection count, resolve via libraryStore - Each view determines coverArt/coverArtMixed state and calls showBatch()
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
||||
RemovePhantomTracks,
|
||||
FindDuplicateTracksInPlaylist,
|
||||
} from '@go/playlist/Service';
|
||||
import type { playlist } from '@go/models';
|
||||
import type { playlist, library } from '@go/models';
|
||||
import { EventsOn } from '@runtime/runtime';
|
||||
import { Events } from '../../events';
|
||||
import { queueStore } from '@store/queue-store';
|
||||
@@ -350,7 +350,11 @@ export class PlaylistDetails
|
||||
void this.removeSelectedTracks();
|
||||
break;
|
||||
case 'track-details':
|
||||
this.openTrackDetails(filePaths[0]!);
|
||||
if (filePaths.length === 1) {
|
||||
this.openTrackDetails(filePaths[0]!);
|
||||
} else {
|
||||
this.openBatchTrackDetails(filePaths);
|
||||
}
|
||||
break;
|
||||
case 'phantom-locate':
|
||||
this.openPhantomResolver();
|
||||
@@ -446,6 +450,50 @@ export class PlaylistDetails
|
||||
);
|
||||
}
|
||||
|
||||
private openBatchTrackDetails(
|
||||
filePaths: string[],
|
||||
) {
|
||||
const cachedTracks =
|
||||
libraryStore.getCachedTracks();
|
||||
|
||||
if (!cachedTracks) return;
|
||||
|
||||
const tracks = filePaths
|
||||
.map((fp) =>
|
||||
cachedTracks.find(
|
||||
(t) => t.FilePath === fp,
|
||||
),
|
||||
)
|
||||
.filter(
|
||||
(t): t is library.Track =>
|
||||
t != null,
|
||||
);
|
||||
|
||||
if (tracks.length === 0) return;
|
||||
|
||||
const albumNames = new Set(
|
||||
tracks.map((t) => t.Album),
|
||||
);
|
||||
let coverArt: CoverArtUrls | null = null;
|
||||
let coverArtMixed = false;
|
||||
|
||||
if (albumNames.size === 1) {
|
||||
const albumName = [...albumNames][0]!;
|
||||
coverArt =
|
||||
this.resolvePlaylistCoverArt(
|
||||
albumName,
|
||||
);
|
||||
} else {
|
||||
coverArtMixed = true;
|
||||
}
|
||||
|
||||
this.trackDetailsDialog?.showBatch(
|
||||
tracks,
|
||||
coverArt,
|
||||
coverArtMixed,
|
||||
);
|
||||
}
|
||||
|
||||
private resolvePlaylistCoverArt(
|
||||
albumName: string,
|
||||
): CoverArtUrls | null {
|
||||
|
||||
Reference in New Issue
Block a user