From 42a5fdf9a14bee31bb337e58ade98d0800ffc8f0 Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Tue, 14 Dec 2021 11:06:21 -0500 Subject: [PATCH] Don't invoke scrobble function if source has no plays If source does not have new OR existing plays to check against clients there is no reason to call scrobble function --- sources/AbstractSource.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sources/AbstractSource.js b/sources/AbstractSource.js index a70f0b31..b92d84b9 100644 --- a/sources/AbstractSource.js +++ b/sources/AbstractSource.js @@ -160,14 +160,18 @@ export default class AbstractSource { checksOverThreshold = 0; } - // use the source instantiation time or the last track play time to determine if we should refresh clients.. - // we only need to refresh clients when the source has "newer" information otherwise we're just refreshing clients for no reason - const scrobbleResult = await allClients.scrobble(playObjs, { - checkTime: lastTrackPlayedAt.add(2, 's'), - forceRefresh: closeToInterval, - scrobbleFrom: this.identifier, - scrobbleTo: this.clients - }); + let scrobbleResult = []; + + if(playObjs.length > 0) { + // use the source instantiation time or the last track play time to determine if we should refresh clients... + // we only need to refresh clients when the source has "newer" information otherwise we're just refreshing clients for no reason + scrobbleResult = await allClients.scrobble(playObjs, { + checkTime: lastTrackPlayedAt.add(2, 's'), + forceRefresh: closeToInterval, + scrobbleFrom: this.identifier, + scrobbleTo: this.clients + }); + } if (scrobbleResult.length > 0) { checkCount = 0; -- 2.51.2