Fix issue with tracking being blank

This commit is contained in:
Wizzard 2024-08-08 11:54:51 -04:00
parent 9a51147fce
commit 11ba548051
1 changed files with 5 additions and 4 deletions

View File

@ -9,13 +9,14 @@ const updateInterval = 5000;
const retryInterval = 30000; const retryInterval = 30000;
const restartInterval = 2 * 60 * 60 * 1000; const restartInterval = 2 * 60 * 60 * 1000;
const reconnectDelay = 10000; const reconnectDelay = 10000;
const extendedReconnectDelay = 90000; const extendedReconnectDelay = 30000;
let rp; let rp;
let startTime = Date.now(); let startTime = Date.now();
let reconnecting = false; let reconnecting = false;
let lastTrack = null; let lastTrack = null;
let currentClient = null; let currentClient = null;
let forceUpdate = false;
function formatNumber(number) { function formatNumber(number) {
var x = number.split("."); var x = number.split(".");
@ -36,7 +37,7 @@ function createClient() {
rp.on("ready", () => { rp.on("ready", () => {
console.log("Connected to Discord!"); console.log("Connected to Discord!");
updateStatus(); updateStatus(true);
}); });
rp.on("disconnected", () => { rp.on("disconnected", () => {
@ -89,7 +90,7 @@ function reconnect(errorType) {
}, delay); }, delay);
} }
async function updateStatus() { async function updateStatus(force = false) {
try { try {
const data = await fetchCurrentScrobble(config.username); const data = await fetchCurrentScrobble(config.username);
if (!data || !rp) { if (!data || !rp) {
@ -98,7 +99,7 @@ async function updateStatus() {
return; return;
} }
if (lastTrack && lastTrack.trackName === data.trackName && lastTrack.artist === data.artist) { if (!force && lastTrack && lastTrack.trackName === data.trackName && lastTrack.artist === data.artist) {
console.log("Same track, skipping update."); console.log("Same track, skipping update.");
setTimeout(updateStatus, updateInterval); setTimeout(updateStatus, updateInterval);
return; return;