fix share

This commit is contained in:
booploops 2022-07-29 00:43:58 -07:00
parent b28dacf845
commit 5920e82a30

View file

@ -452,10 +452,16 @@
{ {
"icon": "./assets/feather/share.svg", "icon": "./assets/feather/share.svg",
"name": app.getLz('action.share'), "name": app.getLz('action.share'),
"action": function () { "action": async function () {
if (!self.item.attributes.url && self.item.relationships) { let item = self.item
if (self.item.relationships.catalog) { if (!item.attributes.url) {
app.mkapi(self.item.attributes.playParams?.kind, false, self.item.relationships.catalog.data[0].id).then(u => { self.app.copyToClipboard((u.data.data.length && u.data.data.length > 0) ? u.data.data[0].attributes.url : u.data.data.attributes.url) }) if (item.type.includes("library")) {
let result = (await app.mk.api.v3.music(`/v1/me/library/${item.type.replace("library-", '')}/${item.id}/catalog`)).data.data[0]
if(result.attributes.url) {
self.app.copyToClipboard(result.attributes.url)
}else{
notyf.error("Failed to get share URL")
}
} }
} else { } else {
self.app.copyToClipboard(self.item.attributes.url) self.app.copyToClipboard(self.item.attributes.url)
@ -465,10 +471,16 @@
{ {
"icon": "./assets/feather/share.svg", "icon": "./assets/feather/share.svg",
"name": `${app.getLz('action.share')} (song.link)`, "name": `${app.getLz('action.share')} (song.link)`,
"action": function () { "action": async function () {
if (!self.item.attributes.url && self.item.relationships) { let item = self.item
if (self.item.relationships.catalog) { if (!item.attributes.url) {
app.mkapi(self.item.attributes.playParams?.kind, false, self.item.relationships.catalog.data[0].id).then(u => { self.app.songLinkShare((u.data.data.length && u.data.data.length > 0) ? u.data.data[0].attributes.url : u.data.data.attributes.url) }) if (item.type.includes("library")) {
let result = (await app.mk.api.v3.music(`/v1/me/library/${item.type.replace("library-", '')}/${item.id}/catalog`)).data.data[0]
if(result.attributes.url) {
self.app.copyToClipboard(result.attributes.url)
}else{
notyf.error("Failed to get share URL")
}
} }
} else { } else {
self.app.songLinkShare(self.item.attributes.url) self.app.songLinkShare(self.item.attributes.url)