From 3fe77473f16ee4ec24260ad06bfa0b5ddffa5afe Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Thu, 1 May 2025 21:44:03 -0600 Subject: [PATCH] presence: inline time --- src/modules/utility/presence.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/modules/utility/presence.js b/src/modules/utility/presence.js index e3d1612..946b57c 100644 --- a/src/modules/utility/presence.js +++ b/src/modules/utility/presence.js @@ -227,18 +227,15 @@ presence.callback = async function (msg, line) { const timeEnd = formatTime(length); const timePos = formatTime(position); + const numBarChars = NOWPLAYING_BAR_LENGTH - timePos.length - timeEnd.length - 2; + const progress = position >= length ? 1 : position / length; - const barLength = Math.round(progress * NOWPLAYING_BAR_LENGTH); - - const bar = `\`\`\`ansi\n${NOWPLAYING_BAR_CHAR.repeat(barLength)}\x1b[30m${NOWPLAYING_BAR_CHAR.repeat( - NOWPLAYING_BAR_LENGTH - barLength - )}\x1b[39m`; - const time = `${timePos}${" ".repeat( - NOWPLAYING_BAR_LENGTH - timePos.length - timeEnd.length - )}${timeEnd}\`\`\``; + const barLength = Math.round(progress * numBarChars); + const bar = `\`\`\`ansi\n${timePos} ${NOWPLAYING_BAR_CHAR.repeat( + barLength + )}\x1b[30m${NOWPLAYING_BAR_CHAR.repeat(numBarChars - barLength)}\x1b[39m ${timeEnd}`; descLines.push(bar); - descLines.push(time); } }