Merge pull request #966 from ciderapp/feature/heartcolumn

Implemented showing Love Status on the Songs page
This commit is contained in:
Amaru8 2022-04-30 19:49:48 +02:00 committed by GitHub
commit 3497b65d6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-heart"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path></svg>

After

Width:  |  Height:  |  Size: 379 B

View file

@ -67,6 +67,9 @@
</div> </div>
<div class="explicit-icon" v-if="item.attributes && item.attributes.contentRating == 'explicit'"></div> <div class="explicit-icon" v-if="item.attributes && item.attributes.contentRating == 'explicit'"></div>
<template v-if="showMetaData == true" @dblclick="route()"> <template v-if="showMetaData == true" @dblclick="route()">
<div class="metainfo" style="min-width: 70px;" v-if="isLoved">
<div class="svg-icon" :style="{'--url': 'url(./assets/feather/heart-fill.svg)'}"></div>
</div>
<div class="metainfo"> <div class="metainfo">
{{ item.attributes.releaseDate ? new Date(item.attributes.releaseDate).toLocaleDateString() {{ item.attributes.releaseDate ? new Date(item.attributes.releaseDate).toLocaleDateString()
: "" }} : "" }}
@ -98,7 +101,8 @@
displayDuration: true, displayDuration: true,
addClasses: {}, addClasses: {},
itemId: 0, itemId: 0,
isLibrary: false isLibrary: false,
isLoved: null
} }
}, },
props: { props: {
@ -121,6 +125,9 @@
} else { } else {
this.itemId = this.item.id; this.itemId = this.item.id;
} }
if (this.item.attributes.playParams) {
this.getHeartStatus();
}
let duration = this.item.attributes.durationInMillis ?? 0 let duration = this.item.attributes.durationInMillis ?? 0
if (duration == 0 || !this.showDuration) { if (duration == 0 || !this.showDuration) {
this.displayDuration = false this.displayDuration = false
@ -323,6 +330,7 @@
"hidden": false, "hidden": false,
"disabled": true, "disabled": true,
"action": function () { "action": function () {
self.isLoved = true
app.love(self.item) app.love(self.item)
} }
}, },
@ -333,6 +341,7 @@
"name": this.app.getLz('action.unlove'), "name": this.app.getLz('action.unlove'),
"hidden": true, "hidden": true,
"action": function () { "action": function () {
self.isLoved = false
app.unlove(self.item) app.unlove(self.item)
} }
}, },
@ -499,6 +508,19 @@
visibilityChanged: function (isVisible, entry) { visibilityChanged: function (isVisible, entry) {
this.isVisible = isVisible this.isVisible = isVisible
}, },
async getHeartStatus() {
try {
await app.getRating(this.item).then(res => {
if (res == 1) {
this.isLoved = true
} else {
this.isLoved = false
}
})
} catch (err) {
console.log(err)
}
},
addToLibrary() { addToLibrary() {
let item = this.item let item = this.item
if (item.attributes.playParams.id) { if (item.attributes.playParams.id) {