mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-07-09 17:28:28 +00:00
fix: Fix typing for play update events
Some checks are pending
Publish Docker image to Dockerhub / test (push) Waiting to run
Publish Docker image to Dockerhub / Build OCI Images (push) Blocked by required conditions
Publish Docker image to Dockerhub / Build OCI Images-1 (push) Blocked by required conditions
Publish Docker image to Dockerhub / Merge OCI Images and Push (push) Blocked by required conditions
Some checks are pending
Publish Docker image to Dockerhub / test (push) Waiting to run
Publish Docker image to Dockerhub / Build OCI Images (push) Blocked by required conditions
Publish Docker image to Dockerhub / Build OCI Images-1 (push) Blocked by required conditions
Publish Docker image to Dockerhub / Merge OCI Images and Push (push) Blocked by required conditions
This commit is contained in:
parent
e998006e6c
commit
94d3ea5da8
3 changed files with 8 additions and 5 deletions
|
|
@ -549,7 +549,7 @@ export default abstract class AbstractComponent extends AbstractInitializable {
|
|||
});
|
||||
}
|
||||
|
||||
protected emitComponentUpdate = (payload: Partial<typeof this.getApiData>) => {
|
||||
protected emitComponentUpdate = <T = Partial<typeof this.getApiData>>(payload: T) => {
|
||||
this.emitEvent('componentUpdate', payload);
|
||||
}
|
||||
protected emitPlayUpdate = (payload: MarkRequired<Partial<PlayApiCommonDetailed>, 'uid'>) => {
|
||||
|
|
|
|||
|
|
@ -1185,6 +1185,8 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i
|
|||
const queueState = currQueuedPlay.queueStates.find(x => x.queueName === CLIENT_INGRESS_QUEUE);
|
||||
if(queueError !== undefined) {
|
||||
await this.queueRepo.updateById(queueState.id, {queueStatus: 'failed', error: queueError});
|
||||
queueState.queueStatus = 'failed';
|
||||
queueState.error = queueError;
|
||||
await this.playRepo.updateById(currQueuedPlay.id, {state: 'failed', error: queueError, play: currQueuedPlay.play});
|
||||
currQueuedPlay.state = 'failed';
|
||||
currQueuedPlay.error = queueError;
|
||||
|
|
@ -1192,8 +1194,9 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i
|
|||
await this.queueRepo.updateById(queueState.id, {queueStatus: 'completed'});
|
||||
await this.playRepo.updateById(currQueuedPlay.id, {state: successState ?? 'scrobbled', play: currQueuedPlay.play});
|
||||
currQueuedPlay.state = successState ?? 'scrobbled';
|
||||
queueState.queueStatus = 'completed';
|
||||
}
|
||||
this.emitPlayUpdate(currQueuedPlay);
|
||||
this.emitPlayUpdate({...currQueuedPlay, queueStates: [queueState]} as unknown as PlayApiCommonDetailed);
|
||||
this.emitEvent('scrobbleDequeued', { queuedScrobble: currQueuedPlay })
|
||||
this.queuedGauge.labels(this.getPrometheusLabels()).dec();
|
||||
this.queuedLength -= 1;
|
||||
|
|
@ -1496,7 +1499,7 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i
|
|||
});
|
||||
|
||||
const playRow = await this.playRepo.createPlays([createPlayData]);
|
||||
await this.queueRepo.create({componentId: this.dbComponent.id, playId: playRow[0].id, queueName: CLIENT_INGRESS_QUEUE});
|
||||
const queueState = await this.queueRepo.create({componentId: this.dbComponent.id, playId: playRow[0].id, queueName: CLIENT_INGRESS_QUEUE});
|
||||
createdQueuedPlays.push(playRow[0]);
|
||||
this.logger.debug(`Added ${buildTrackString(play)} to the queue`);
|
||||
this.setStatus(`Added Play from parent ${play.uid} to queue`);
|
||||
|
|
@ -1504,7 +1507,7 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i
|
|||
const queuedPlay = {id: nanoid(), source, play: play}
|
||||
//await this.playRepo.updateById(play.meta.dbId, {play});
|
||||
this.emitEvent('scrobbleQueued', {queuedPlay: queuedPlay});
|
||||
this.emitPlayInsert(playRow[0]);
|
||||
this.emitPlayInsert({...playRow[0], queueStates: [queueState]} as unknown as PlayApiCommonDetailed);
|
||||
this.queuedLength += 1;
|
||||
//this.queuedScrobbles.push(queuedPlay);
|
||||
this.queuedGauge.labels(this.getPrometheusLabels()).inc();
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ export default abstract class AbstractSource extends AbstractComponent implement
|
|||
this.tracksDiscovered++;
|
||||
this.logger.info(`Discovered => ${buildTrackString(play)}`);
|
||||
this.emitEvent('discovered', {play});
|
||||
this.emitPlayInsert(playRow);
|
||||
this.emitPlayInsert({...playRow[0], queueStates: []} as unknown as PlayApiCommonDetailed);
|
||||
this.discoveredCounter.labels(this.getPrometheusLabels()).inc();
|
||||
play.id = playRow[0].id;
|
||||
play.uid = playRow[0].uid;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue