From 3b46a623cd48be3a0f62cf94ef25165fc8a3c01a Mon Sep 17 00:00:00 2001 From: Core Date: Tue, 13 Sep 2022 18:07:42 +0100 Subject: [PATCH] simplified preload function Signed-off-by: Core --- src/preload/cider-preload.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/preload/cider-preload.js b/src/preload/cider-preload.js index 324c2891..e8c62551 100644 --- a/src/preload/cider-preload.js +++ b/src/preload/cider-preload.js @@ -83,7 +83,8 @@ const MusicKitInterop = { }); }, - async fetchSongRelationships({ id = app.mk.nowPlayingItem.attributes.playParams.catalogId || app.mk.nowPlayingItem.attributes.playParams.id, relationship = "primaryName" } = {}) { + async fetchSongRelationships({ id = this.getAttributes().songId, relationship = "primaryName" } = {}) { + if (!id) return null; const res = await MusicKit.getInstance().api.v3.music("/v1/catalog/" + MusicKit.getInstance().storefrontId + `/songs/${id}`, { include: { songs: ["artists"], @@ -92,14 +93,14 @@ const MusicKitInterop = { if (!res || !res.data) { console.warn("[cider:preload] fetchSongRelationships: no response"); - if (id === app.mk.nowPlayingItem.attributes.playParams.catalogId || id === app.mk.nowPlayingItem.attributes.playParams.id) { - return app.mk.nowPlayingItem.attributes.artistName; + if (id === this.getAttributes().songId) { + return this.getAttributes().artistName; } } if (!res.data.data.length) { console.error(`[cider:preload] fetchSongRelationships: Unable to locate song with id of ${id}`); - if (id === app.mk.nowPlayingItem.attributes.playParams.catalogId || id === app.mk.nowPlayingItem.attributes.playParams.id) { - return app.mk.nowPlayingItem.attributes.artistName; + if (id === this.getAttributes().songId) { + return this.getAttributes().artistName; } }