From 6212f47084befc9aaaed3338a80855200454284c Mon Sep 17 00:00:00 2001 From: creations Date: Sun, 27 Apr 2025 17:57:53 -0400 Subject: [PATCH 1/2] add spotify button based on sync id --- public/js/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/js/index.js b/public/js/index.js index eb38b58..e6ae8fb 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -167,7 +167,7 @@ function buildActivityHTML(activity) { : ""; const activityButtons = - activity.buttons && activity.buttons.length > 0 + (activity.buttons && activity.buttons.length > 0 ? `
${activity.buttons .map((button, index) => { @@ -188,7 +188,12 @@ function buildActivityHTML(activity) { .filter(Boolean) .join("")}
` - : ""; + : "") + + (activity.name === "Spotify" && activity.sync_id + ? `
+ Listen on Spotify +
` + : ""); const progressBar = progress !== null From af872d538c52d3ff203adb0b38d75d1372d8b424 Mon Sep 17 00:00:00 2001 From: creations Date: Sun, 27 Apr 2025 17:58:20 -0400 Subject: [PATCH 2/2] Fix lint --- public/js/index.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/public/js/index.js b/public/js/index.js index e6ae8fb..ad16c65 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -171,10 +171,7 @@ function buildActivityHTML(activity) { ? `
${activity.buttons .map((button, index) => { - const label = - typeof button === "string" - ? button - : button.label; + const label = typeof button === "string" ? button : button.label; let url = null; if (typeof button === "object" && button.url) { url = button.url; @@ -326,9 +323,7 @@ async function populateReadme(data) { if (readmeSection && data.kv?.readme) { const url = data.kv.readme; try { - const res = await fetch( - `/api/readme?url=${encodeURIComponent(url)}`, - ); + const res = await fetch(`/api/readme?url=${encodeURIComponent(url)}`); if (!res.ok) throw new Error("Failed to fetch readme"); const text = await res.text(); @@ -348,9 +343,7 @@ async function updatePresence(data) { const cssLink = data.kv?.css; if (cssLink) { try { - const res = await fetch( - `/api/css?url=${encodeURIComponent(cssLink)}`, - ); + const res = await fetch(`/api/css?url=${encodeURIComponent(cssLink)}`); if (!res.ok) throw new Error("Failed to fetch CSS"); const cssText = await res.text();