From 54817ab5069026421c263d8d71c252b43d4976a9 Mon Sep 17 00:00:00 2001 From: flag <38012125+Yumiro@users.noreply.github.com> Date: Fri, 17 May 2024 17:36:35 +0100 Subject: [PATCH] lastfmRPC: add setting to toggle "View Song" button (#2292) Co-authored-by: vee --- src/plugins/lastfm/index.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/plugins/lastfm/index.tsx b/src/plugins/lastfm/index.tsx index 1213ece2..02fd694f 100644 --- a/src/plugins/lastfm/index.tsx +++ b/src/plugins/lastfm/index.tsx @@ -114,6 +114,11 @@ const settings = definePluginSettings({ type: OptionType.BOOLEAN, default: false, }, + shareSong: { + description: "show link to song on last.fm", + type: OptionType.BOOLEAN, + default: true, + }, hideWithSpotify: { description: "hide last.fm presence if spotify is running", type: OptionType.BOOLEAN, @@ -295,12 +300,7 @@ export default definePlugin({ large_text: trackData.album || undefined, }; - const buttons: ActivityButton[] = [ - { - label: "View Song", - url: trackData.url, - }, - ]; + const buttons: ActivityButton[] = []; if (settings.store.shareUsername) buttons.push({ @@ -308,6 +308,12 @@ export default definePlugin({ url: `https://www.last.fm/user/${settings.store.username}`, }); + if (settings.store.shareSong) + buttons.push({ + label: "View Song", + url: trackData.url, + }); + const statusName = (() => { switch (settings.store.nameFormat) { case NameFormat.ArtistFirst: @@ -333,7 +339,7 @@ export default definePlugin({ state: trackData.artist, assets, - buttons: buttons.map(v => v.label), + buttons: buttons.length ? buttons.map(v => v.label) : undefined, metadata: { button_urls: buttons.map(v => v.url), },