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,
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),
},