From dabb3305d086e1d7122338de0e71440cfa726ffa Mon Sep 17 00:00:00 2001 From: Justin James Date: Mon, 23 Dec 2024 11:09:43 -0700 Subject: [PATCH] add: feedback tracking for individual track not part of playlist/artist/album --- src/feedback.ts | 4 ++-- src/main.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/feedback.ts b/src/feedback.ts index 3a9d0d2..3ebdb7f 100644 --- a/src/feedback.ts +++ b/src/feedback.ts @@ -90,8 +90,8 @@ export function GetFeedbacksList(getState: () => SpotifyState): CompanionFeedbac [FeedbackId.CurrentContext]: { type: 'boolean', - name: 'Change button style if current album/artist/playlist id matches value', - description: 'If active album/artist/playlist matches value, change button color', + name: 'Change button style if current album/artist/playlist/track id matches value', + description: 'If active album/artist/playlist/track matches value, change button color', options: [ { type: 'textinput', diff --git a/src/main.ts b/src/main.ts index ee8515b..624eca5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -379,6 +379,13 @@ class SpotifyInstance extends InstanceBase implements SpotifyInsta deviceInfo: null, } + // If an individual track is playing then context is null from Spotify API + // If the current context is null, but a track is playing, then set the context to the track uri + // This allows feedbacks to be triggered when an track is playing + if (newState.currentContext === null && data.body.currently_playing_type === 'track' && data.body.item) { + newState.currentContext = data.body.item.uri.split(':')[2] + } + if (data.body.item) { newState.trackInfo = { durationMs: data.body.item.duration_ms,