Skip to content

Commit 763bfde

Browse files
feat: feedback tracking for individual track not part of playlist/artist/album (#72)
1 parent b473775 commit 763bfde

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Diff for: src/feedback.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ export function GetFeedbacksList(getState: () => SpotifyState): CompanionFeedbac
9090

9191
[FeedbackId.CurrentContext]: {
9292
type: 'boolean',
93-
name: 'Change button style if current album/artist/playlist id matches value',
94-
description: 'If active album/artist/playlist matches value, change button color',
93+
name: 'Change button style if current album/artist/playlist/track id matches value',
94+
description: 'If active album/artist/playlist/track matches value, change button color',
9595
options: [
9696
{
9797
type: 'textinput',

Diff for: src/main.ts

+7
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,13 @@ class SpotifyInstance extends InstanceBase<DeviceConfig> implements SpotifyInsta
379379
deviceInfo: null,
380380
}
381381

382+
// If an individual track is playing then context is null from Spotify API
383+
// If the current context is null, but a track is playing, then set the context to the track uri
384+
// This allows feedbacks to be triggered when an track is playing
385+
if (newState.currentContext === null && data.body.currently_playing_type === 'track' && data.body.item) {
386+
newState.currentContext = data.body.item.uri.split(':')[2]
387+
}
388+
382389
if (data.body.item) {
383390
newState.trackInfo = {
384391
durationMs: data.body.item.duration_ms,

0 commit comments

Comments
 (0)