lastfmRPC: add setting to toggle "View Song" button (#2292)

Co-authored-by: vee <vendicated@riseup.net>
This commit is contained in:
flag 2024-05-17 17:36:35 +01:00 committed by GitHub
parent 5fc6ba86d1
commit 54817ab506
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -114,6 +114,11 @@ const settings = definePluginSettings({
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
default: false, default: false,
}, },
shareSong: {
description: "show link to song on last.fm",
type: OptionType.BOOLEAN,
default: true,
},
hideWithSpotify: { hideWithSpotify: {
description: "hide last.fm presence if spotify is running", description: "hide last.fm presence if spotify is running",
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
@ -295,12 +300,7 @@ export default definePlugin({
large_text: trackData.album || undefined, large_text: trackData.album || undefined,
}; };
const buttons: ActivityButton[] = [ const buttons: ActivityButton[] = [];
{
label: "View Song",
url: trackData.url,
},
];
if (settings.store.shareUsername) if (settings.store.shareUsername)
buttons.push({ buttons.push({
@ -308,6 +308,12 @@ export default definePlugin({
url: `https://www.last.fm/user/${settings.store.username}`, url: `https://www.last.fm/user/${settings.store.username}`,
}); });
if (settings.store.shareSong)
buttons.push({
label: "View Song",
url: trackData.url,
});
const statusName = (() => { const statusName = (() => {
switch (settings.store.nameFormat) { switch (settings.store.nameFormat) {
case NameFormat.ArtistFirst: case NameFormat.ArtistFirst:
@ -333,7 +339,7 @@ export default definePlugin({
state: trackData.artist, state: trackData.artist,
assets, assets,
buttons: buttons.map(v => v.label), buttons: buttons.length ? buttons.map(v => v.label) : undefined,
metadata: { metadata: {
button_urls: buttons.map(v => v.url), button_urls: buttons.map(v => v.url),
}, },