fix(17-02): refresh cover art URLs after save
After a successful save, re-fetch albums alongside tracks and re-resolve cover art URLs from the updated album data. Previously the dialog only refreshed this.track but kept stale this.coverArt URLs pointing to the old content-hash files, causing the image to revert until reopen.
This commit is contained in:
@@ -823,17 +823,38 @@ export class TrackDetails extends LitElement {
|
|||||||
// invalidation, which refreshes all other views.
|
// invalidation, which refreshes all other views.
|
||||||
this.exitEditMode();
|
this.exitEditMode();
|
||||||
|
|
||||||
// Re-fetch the track data so the dialog shows
|
// Re-fetch track and album data so the dialog
|
||||||
// updated values. The store invalidation is
|
// shows updated values and cover art. The store
|
||||||
// already in-flight from the event; getTracks()
|
// invalidation is already in-flight from the event;
|
||||||
// will either await the pending fetch or start one.
|
// these calls await the pending fetch or start one.
|
||||||
const tracks = await libraryStore.getTracks();
|
const [tracks, albums] = await Promise.all([
|
||||||
|
libraryStore.getTracks(),
|
||||||
|
libraryStore.getAlbums(),
|
||||||
|
]);
|
||||||
|
|
||||||
const updated = tracks.find(
|
const updated = tracks.find(
|
||||||
(t) => t.FilePath === filePath,
|
(t) => t.FilePath === filePath,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
this.track = updated;
|
this.track = updated;
|
||||||
|
|
||||||
|
// Re-resolve cover art from the refreshed
|
||||||
|
// album data (URLs change on new content hash).
|
||||||
|
const album = albums.find(
|
||||||
|
(a) => a.Name === updated.Album,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (album?.CoverArtPath) {
|
||||||
|
this.coverArt = {
|
||||||
|
coverArtPath: album.CoverArtPath,
|
||||||
|
coverArtSmall: album.CoverArtSmall,
|
||||||
|
coverArtMedium: album.CoverArtMedium,
|
||||||
|
coverArtLarge: album.CoverArtLarge,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.coverArt = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
const msg =
|
const msg =
|
||||||
|
|||||||
Reference in New Issue
Block a user