From 2205fa168ddc8fe4bb873ad70db8f57a2292b96b Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Fri, 29 Mar 2024 16:13:09 -0700 Subject: [PATCH] chore: scrobbling --- api/scrobble.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/scrobble.js b/api/scrobble.js index af3ea783..6adbeacf 100644 --- a/api/scrobble.js +++ b/api/scrobble.js @@ -114,10 +114,10 @@ export default async (request) => { await scrobbles.setJSON('now-playing', {...trackScrobbleData, ...{ url: `https://musicbrainz.org/artist/${artistInfo?.['mbid']}`}}) let scrobbleUpdate = scrobbleData let windowUpdate = windowData; - if (scrobbleUpdate['data']) scrobbleUpdate['data'].push(trackScrobbleData) - if (!scrobbleUpdate['data']) scrobbleUpdate = { data: [trackScrobbleData] } - if (windowData['data']) windowUpdate['data'].push(trackScrobbleData) - if (!windowData['data']) windowUpdate = { data: [trackScrobbleData] } + if (scrobbleUpdate?.['data']) scrobbleUpdate['data'].push(trackScrobbleData) + if (!scrobbleUpdate?.['data']) scrobbleUpdate = { data: [trackScrobbleData] } + if (windowData?.['data']) windowUpdate['data'].push(trackScrobbleData) + if (!windowData?.['data']) windowUpdate = { data: [trackScrobbleData] } windowUpdate = { data: filterOldScrobbles(windowUpdate.data) } await scrobbles.setJSON(`${weekStop()}`, scrobbleUpdate) await scrobbles.setJSON('window', windowUpdate)