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"
: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)'>
<div class="item-navigate text-overflow-elipsis">{{ item.attributes?.name.replace(/&nbsp;/g, '
').replace(/Apple Music |^Apple |/g, '') ??
<div class="item-navigate text-overflow-elipsis">{{ item.attributes?.name.replace(/&nbsp;/g, ' ').replace(/Apple Music |^Apple |/g, '') ??
(item.relationships?.contents?.data[0]?.attributes?.name ??
(item.attributes?.editorialNotes?.name ?? '')) }}
</div>
@ -65,7 +64,7 @@
</script>
<script>
Vue.component('mediaitem-square', {
Vue.component('mediaitem-square', {
template: '#mediaitem-square',
props: {
item: {
@ -101,7 +100,7 @@
},
'contextExt': { type: Object, required: false },
},
data: function() {
data: function () {
return {
isVisible: false,
addedToLibrary: false,
@ -185,7 +184,7 @@
if (id && this.badges[id]) {
let friends = this.badges[id]
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.itemBadges.push(data.data.data[0])
})
@ -248,11 +247,11 @@
getArtworkUrl(size = -1, includeUrl = false) {
let artwork = this.item?.attributes?.artwork ? this.item?.attributes?.artwork?.url : (this.item?.attributes?.editorialArtwork?.subscriptionCover?.url ?? '')
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) {
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;
}
if (!includeUrl) {
@ -264,7 +263,7 @@
getClasses() {
let type = []
let classes = []
if (this.noScale) {
if(this.noScale) {
classes.push("noscale")
}
try {
@ -300,7 +299,7 @@
}
return classes
},
visibilityChanged: function(isVisible, entry) {
visibilityChanged: function (isVisible, entry) {
this.isVisible = isVisible
},
async contextMenu(event) {
@ -376,7 +375,7 @@
"name": app.getLz('action.love'),
"hidden": false,
"disabled": true,
"action": function() {
"action": function () {
app.love(self.item)
}
},
@ -386,7 +385,7 @@
"active": true,
"name": app.getLz('action.unlove'),
"hidden": true,
"action": function() {
"action": function () {
app.unlove(self.item)
}
},
@ -396,7 +395,7 @@
"name": app.getLz('action.dislike'),
"hidden": false,
"disabled": true,
"action": function() {
"action": function () {
app.dislike(self.item)
}
},
@ -406,7 +405,7 @@
"name": app.getLz('action.undoDislike'),
"active": true,
"hidden": true,
"action": function() {
"action": function () {
app.unlove(self.item)
}
},
@ -416,7 +415,7 @@
"icon": "./assets/feather/list.svg",
"id": "addToPlaylist",
"name": app.getLz('action.addToPlaylist'),
"action": function() {
"action": function () {
app.promptAddToPlaylist()
}
},
@ -426,7 +425,7 @@
"name": app.getLz('action.addToLibrary'),
"hidden": false,
"disabled": true,
"action": function() {
"action": function () {
let item_id = self.item.attributes.playParams.id ?? self.item.id;
let data_type = self.item.attributes.playParams.kind ?? self.item.type;
app.addToLibrary(item_id);
@ -438,7 +437,7 @@
"icon": "./assets/feather/x-circle.svg",
"name": app.getLz('action.removeFromLibrary'),
"hidden": true,
"action": async function() {
"action": async function () {
console.log("remove");
let item_id = self.item.attributes.playParams.id ?? self.item.id;
let data_type = self.item.attributes.playParams.kind ?? self.item.type;
@ -449,7 +448,7 @@
{
"name": app.getLz('action.playNext'),
"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.queue._reindex()
app.selectedMediaItems = []
@ -458,7 +457,7 @@
{
"name": app.getLz('action.playLater'),
"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.queue._reindex()
app.selectedMediaItems = []
@ -467,7 +466,7 @@
{
"icon": "./assets/feather/share.svg",
"name": app.getLz('action.share'),
"action": function() {
"action": function () {
if (!self.item.attributes.url && self.item.relationships) {
if (self.item.relationships.catalog) {
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",
"name": `${app.getLz('action.share')} (song.link)`,
"action": function() {
"action": function () {
if (!self.item.attributes.url && self.item.relationships) {
if (self.item.relationships.catalog) {
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")) {
// 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"
})
}
@ -596,10 +595,10 @@
}, event)
},
},
beforeDestroy: function() {
beforeDestroy: function () {
// this.item = null;
// this.kind = null;
// this.size = null;
}
});
});
</script>