fixed square

This commit is contained in:
booploops 2022-08-03 22:09:11 -07:00
parent 8f7af275f1
commit 2553fce33d

View file

@ -45,8 +45,7 @@
<div class="title" <div class="title"
:title="item.attributes?.name ?? (item.relationships?.contents?.data[0]?.attributes?.name ?? (item.attributes?.editorialNotes?.name ?? ''))" :title="item.attributes?.name ?? (item.relationships?.contents?.data[0]?.attributes?.name ?? (item.attributes?.editorialNotes?.name ?? ''))"
v-if="item.attributes.artistNames == null || kind != 'card'" @click='app.routeView(item)'> v-if="item.attributes.artistNames == null || kind != 'card'" @click='app.routeView(item)'>
<div class="item-navigate text-overflow-elipsis">{{ item.attributes?.name.replace(/&nbsp;/g, ' <div class="item-navigate text-overflow-elipsis">{{ item.attributes?.name.replace(/&nbsp;/g, ' ').replace(/Apple Music |^Apple |/g, '') ??
').replace(/Apple Music |^Apple |/g, '') ??
(item.relationships?.contents?.data[0]?.attributes?.name ?? (item.relationships?.contents?.data[0]?.attributes?.name ??
(item.attributes?.editorialNotes?.name ?? '')) }} (item.attributes?.editorialNotes?.name ?? '')) }}
</div> </div>
@ -65,7 +64,7 @@
</script> </script>
<script> <script>
Vue.component('mediaitem-square', { Vue.component('mediaitem-square', {
template: '#mediaitem-square', template: '#mediaitem-square',
props: { props: {
item: { item: {
@ -101,7 +100,7 @@
}, },
'contextExt': { type: Object, required: false }, 'contextExt': { type: Object, required: false },
}, },
data: function() { data: function () {
return { return {
isVisible: false, isVisible: false,
addedToLibrary: false, addedToLibrary: false,
@ -185,7 +184,7 @@
if (id && this.badges[id]) { if (id && this.badges[id]) {
let friends = this.badges[id] let friends = this.badges[id]
if (friends) { if (friends) {
friends.forEach(function(friend) { friends.forEach(function (friend) {
self.app.mk.api.v3.music(`/v1/social/${app.mk.storefrontId}/social-profiles/${friend}`).then(data => { self.app.mk.api.v3.music(`/v1/social/${app.mk.storefrontId}/social-profiles/${friend}`).then(data => {
self.itemBadges.push(data.data.data[0]) self.itemBadges.push(data.data.data[0])
}) })
@ -248,11 +247,11 @@
getArtworkUrl(size = -1, includeUrl = false) { getArtworkUrl(size = -1, includeUrl = false) {
let artwork = this.item?.attributes?.artwork ? this.item?.attributes?.artwork?.url : (this.item?.attributes?.editorialArtwork?.subscriptionCover?.url ?? '') let artwork = this.item?.attributes?.artwork ? this.item?.attributes?.artwork?.url : (this.item?.attributes?.editorialArtwork?.subscriptionCover?.url ?? '')
if (size != -1) { if (size != -1) {
artwork = artwork.replace('{w}', size).replace('{h}', size).replace('{f}', "webp").replace('{c}', (size === 900 || size === 380 || size === 600) ? "sr" : this.imageformat); artwork = artwork.replace('{w}', size).replace('{h}', size).replace('{f}', "webp").replace('{c}', (size === 900 || size === 380 || size === 600 ) ? "sr" : this.imageformat);
} }
switch (this.kind) { switch (this.kind) {
case "385": case "385":
artwork = (this.item.attributes.editorialArtwork?.subscriptionHero?.url ?? (this.item.attributes.artwork?.url ?? (this.item.relationships?.contents?.data[0]?.attributes?.editorialArtwork?.subscriptionHero?.url ?? ''))).replace('{c}', (size === 900 || size === 380 || size === 600) ? "sr" : this.imageformat); artwork = (this.item.attributes.editorialArtwork?.subscriptionHero?.url ?? (this.item.attributes.artwork?.url ?? (this.item.relationships?.contents?.data[0]?.attributes?.editorialArtwork?.subscriptionHero?.url ?? ''))).replace('{c}', (size === 900 || size === 380 || size === 600 ) ? "sr" : this.imageformat);
break; break;
} }
if (!includeUrl) { if (!includeUrl) {
@ -264,7 +263,7 @@
getClasses() { getClasses() {
let type = [] let type = []
let classes = [] let classes = []
if (this.noScale) { if(this.noScale) {
classes.push("noscale") classes.push("noscale")
} }
try { try {
@ -300,7 +299,7 @@
} }
return classes return classes
}, },
visibilityChanged: function(isVisible, entry) { visibilityChanged: function (isVisible, entry) {
this.isVisible = isVisible this.isVisible = isVisible
}, },
async contextMenu(event) { async contextMenu(event) {
@ -376,7 +375,7 @@
"name": app.getLz('action.love'), "name": app.getLz('action.love'),
"hidden": false, "hidden": false,
"disabled": true, "disabled": true,
"action": function() { "action": function () {
app.love(self.item) app.love(self.item)
} }
}, },
@ -386,7 +385,7 @@
"active": true, "active": true,
"name": app.getLz('action.unlove'), "name": app.getLz('action.unlove'),
"hidden": true, "hidden": true,
"action": function() { "action": function () {
app.unlove(self.item) app.unlove(self.item)
} }
}, },
@ -396,7 +395,7 @@
"name": app.getLz('action.dislike'), "name": app.getLz('action.dislike'),
"hidden": false, "hidden": false,
"disabled": true, "disabled": true,
"action": function() { "action": function () {
app.dislike(self.item) app.dislike(self.item)
} }
}, },
@ -406,7 +405,7 @@
"name": app.getLz('action.undoDislike'), "name": app.getLz('action.undoDislike'),
"active": true, "active": true,
"hidden": true, "hidden": true,
"action": function() { "action": function () {
app.unlove(self.item) app.unlove(self.item)
} }
}, },
@ -416,7 +415,7 @@
"icon": "./assets/feather/list.svg", "icon": "./assets/feather/list.svg",
"id": "addToPlaylist", "id": "addToPlaylist",
"name": app.getLz('action.addToPlaylist'), "name": app.getLz('action.addToPlaylist'),
"action": function() { "action": function () {
app.promptAddToPlaylist() app.promptAddToPlaylist()
} }
}, },
@ -426,7 +425,7 @@
"name": app.getLz('action.addToLibrary'), "name": app.getLz('action.addToLibrary'),
"hidden": false, "hidden": false,
"disabled": true, "disabled": true,
"action": function() { "action": function () {
let item_id = self.item.attributes.playParams.id ?? self.item.id; let item_id = self.item.attributes.playParams.id ?? self.item.id;
let data_type = self.item.attributes.playParams.kind ?? self.item.type; let data_type = self.item.attributes.playParams.kind ?? self.item.type;
app.addToLibrary(item_id); app.addToLibrary(item_id);
@ -438,7 +437,7 @@
"icon": "./assets/feather/x-circle.svg", "icon": "./assets/feather/x-circle.svg",
"name": app.getLz('action.removeFromLibrary'), "name": app.getLz('action.removeFromLibrary'),
"hidden": true, "hidden": true,
"action": async function() { "action": async function () {
console.log("remove"); console.log("remove");
let item_id = self.item.attributes.playParams.id ?? self.item.id; let item_id = self.item.attributes.playParams.id ?? self.item.id;
let data_type = self.item.attributes.playParams.kind ?? self.item.type; let data_type = self.item.attributes.playParams.kind ?? self.item.type;
@ -449,7 +448,7 @@
{ {
"name": app.getLz('action.playNext'), "name": app.getLz('action.playNext'),
"icon": "./assets/arrow-bend-up.svg", "icon": "./assets/arrow-bend-up.svg",
"action": function() { "action": function () {
app.mk.playNext({ [self.item.attributes.playParams.kind ?? self.item.type]: self.item.attributes.playParams.id ?? self.item.id }) app.mk.playNext({ [self.item.attributes.playParams.kind ?? self.item.type]: self.item.attributes.playParams.id ?? self.item.id })
app.mk.queue._reindex() app.mk.queue._reindex()
app.selectedMediaItems = [] app.selectedMediaItems = []
@ -458,7 +457,7 @@
{ {
"name": app.getLz('action.playLater'), "name": app.getLz('action.playLater'),
"icon": "./assets/arrow-bend-down.svg", "icon": "./assets/arrow-bend-down.svg",
"action": function() { "action": function () {
app.mk.playLater({ [self.item.attributes.playParams.kind ?? self.item.type]: self.item.attributes.playParams.id ?? self.item.id }) app.mk.playLater({ [self.item.attributes.playParams.kind ?? self.item.type]: self.item.attributes.playParams.id ?? self.item.id })
app.mk.queue._reindex() app.mk.queue._reindex()
app.selectedMediaItems = [] app.selectedMediaItems = []
@ -467,7 +466,7 @@
{ {
"icon": "./assets/feather/share.svg", "icon": "./assets/feather/share.svg",
"name": app.getLz('action.share'), "name": app.getLz('action.share'),
"action": function() { "action": function () {
if (!self.item.attributes.url && self.item.relationships) { if (!self.item.attributes.url && self.item.relationships) {
if (self.item.relationships.catalog) { if (self.item.relationships.catalog) {
app.mkapi(self.item.attributes.playParams.kind, false, self.item.relationships.catalog.data[0].id).then(u => { app.mkapi(self.item.attributes.playParams.kind, false, self.item.relationships.catalog.data[0].id).then(u => {
@ -482,7 +481,7 @@
{ {
"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": function () {
if (!self.item.attributes.url && self.item.relationships) { if (!self.item.attributes.url && self.item.relationships) {
if (self.item.relationships.catalog) { if (self.item.relationships.catalog) {
app.mkapi(self.item.attributes.playParams.kind, false, self.item.relationships.catalog.data[0].id).then(u => { app.mkapi(self.item.attributes.playParams.kind, false, self.item.relationships.catalog.data[0].id).then(u => {
@ -499,7 +498,7 @@
} }
if ((self.item.attributes.playParams.kind ?? self.item.type).includes("playlist")) { if ((self.item.attributes.playParams.kind ?? self.item.type).includes("playlist")) {
// remove the add to playlist option by id "addToPlaylist" using the .filter() method // remove the add to playlist option by id "addToPlaylist" using the .filter() method
menus.normal.items = menus.normal.items.filter(function(item) { menus.normal.items = menus.normal.items.filter(function (item) {
return item.id != "addToPlaylist" return item.id != "addToPlaylist"
}) })
} }
@ -596,10 +595,10 @@
}, event) }, event)
}, },
}, },
beforeDestroy: function() { beforeDestroy: function () {
// this.item = null; // this.item = null;
// this.kind = null; // this.kind = null;
// this.size = null; // this.size = null;
} }
}); });
</script> </script>