From aefda8bd5151eb8ee817d2f896c51da51f088cf6 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 30 Mar 2024 11:40:35 -0500 Subject: [PATCH] Fix:Local sessions set date and dayOfWeek using the updatedAt timestamp passed in from the client #2795 --- server/managers/PlaybackSessionManager.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/managers/PlaybackSessionManager.js b/server/managers/PlaybackSessionManager.js index 879dff7ed0..99ddb47a6c 100644 --- a/server/managers/PlaybackSessionManager.js +++ b/server/managers/PlaybackSessionManager.js @@ -144,8 +144,13 @@ class PlaybackSessionManager { session.currentTime = sessionJson.currentTime session.timeListening = sessionJson.timeListening session.updatedAt = sessionJson.updatedAt - session.date = date.format(new Date(), 'YYYY-MM-DD') - session.dayOfWeek = date.format(new Date(), 'dddd') + + let jsDate = new Date(sessionJson.updatedAt) + if (isNaN(jsDate)) { + jsDate = new Date() + } + session.date = date.format(jsDate, 'YYYY-MM-DD') + session.dayOfWeek = date.format(jsDate, 'dddd') Logger.debug(`[PlaybackSessionManager] Updated session for "${session.displayTitle}" (${session.id})`) await Database.updatePlaybackSession(session)