Skip to content

Commit 3d3203a

Browse files
committed
fix: report warning status when deviceId is not configured
1 parent d929d31 commit 3d3203a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: src/main.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ class SpotifyInstance extends InstanceBase<DeviceConfig> implements SpotifyInsta
111111
this.initActions()
112112
}
113113

114+
override updateStatus(status: InstanceStatus, message?: string | null): void {
115+
// Override the implementation so that when the auth checks say 'ok' we can hijack it and report a status based on the selected device
116+
if (status === InstanceStatus.Ok && !this.config.deviceId) {
117+
super.updateStatus(InstanceStatus.BadConfig, 'No playout device selected')
118+
} else {
119+
super.updateStatus(status, message)
120+
}
121+
}
122+
114123
private setupOrRefreshAuthentication(clearToken = false) {
115124
if (clearToken) {
116125
// Clear the access token each time to ensure it is correct
@@ -129,7 +138,7 @@ class SpotifyInstance extends InstanceBase<DeviceConfig> implements SpotifyInsta
129138
this.updateStatus(InstanceStatus.Connecting)
130139

131140
// Fetch then clear the code
132-
const code = this.config.code
141+
const code = this.config.code.trim()
133142
delete this.config.code
134143
this.saveConfig(this.config)
135144

@@ -152,7 +161,7 @@ class SpotifyInstance extends InstanceBase<DeviceConfig> implements SpotifyInsta
152161
})
153162
.catch((err) => {
154163
console.log(err)
155-
this.log('debug', `Failed to get access token: ${err?.message ?? err.toString()}`)
164+
this.log('debug', `Failed to get access token: ${err?.message ?? err?.toString() ?? err}`)
156165
})
157166
} else if (this.config.refreshToken) {
158167
this.updateStatus(InstanceStatus.Connecting)

0 commit comments

Comments
 (0)