some fixes to the heart button
This commit is contained in:
parent
25221521cd
commit
3c92dc5e83
3 changed files with 41 additions and 7 deletions
|
@ -1448,6 +1448,12 @@ const app = new Vue({
|
||||||
self.getLibrarySongsFull(true)
|
self.getLibrarySongsFull(true)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
removeFromLibrary(kind,id) {
|
||||||
|
let self = this
|
||||||
|
this.mk.api.library.remove({[kind]: id }).then((data) => {
|
||||||
|
self.getLibrarySongsFull(true)
|
||||||
|
})
|
||||||
|
},
|
||||||
async loadYTLyrics() {
|
async loadYTLyrics() {
|
||||||
const track = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title ?? '' : '';
|
const track = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title ?? '' : '';
|
||||||
const artist = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName ?? '' : '';
|
const artist = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName ?? '' : '';
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<button @click="addToLibrary()"
|
<button @click="addToLibrary()"
|
||||||
v-if="!app.isInLibrary(item.attributes.playParams) && !addedToLibrary">🖤
|
v-if="!app.isInLibrary(item.attributes.playParams) && !addedToLibrary">🖤
|
||||||
</button>
|
</button>
|
||||||
<button v-else>❤️</button>
|
<button v-else @click="removeFromLibrary()" >❤️</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="artwork" v-if="showArtwork == true">
|
<div class="artwork" v-if="showArtwork == true">
|
||||||
<mediaitem-artwork
|
<mediaitem-artwork
|
||||||
|
@ -295,6 +295,26 @@
|
||||||
this.addedToLibrary = true
|
this.addedToLibrary = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async removeFromLibrary() {
|
||||||
|
let item = this.item
|
||||||
|
let params = {"fields[songs]": "inLibrary","fields[albums]": "inLibrary","relate" : "library"}
|
||||||
|
let id = item.id ?? item.attributes.playParams.id
|
||||||
|
let res = await app.mkapi(item.attributes.playParams.kind ?? item.type, item.attributes.playParams.isLibrary ?? false , item.attributes.playParams.id ?? item.id, params);
|
||||||
|
if (res && res.relationships && res.relationships.library && res.relationships.library.data && res.relationships.library.data.length > 0) {
|
||||||
|
id = res.relationships.library.data[0].id
|
||||||
|
}
|
||||||
|
let kind = this.item.attributes.playParams.kind ?? this.data.item ?? '';
|
||||||
|
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||||
|
if (item.attributes.playParams.id) {
|
||||||
|
console.log('remove from library', id)
|
||||||
|
app.removeFromLibrary(truekind, id)
|
||||||
|
this.addedToLibrary = false
|
||||||
|
} else if (item.id) {
|
||||||
|
console.log('remove from library', id)
|
||||||
|
app.removeFromLibrary(truekind, id)
|
||||||
|
this.addedToLibrary = false
|
||||||
|
}
|
||||||
|
},
|
||||||
playTrack() {
|
playTrack() {
|
||||||
let item = this.item
|
let item = this.item
|
||||||
let parent = this.parent
|
let parent = this.parent
|
||||||
|
|
|
@ -109,11 +109,13 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async isInLibrary () {
|
async isInLibrary () {
|
||||||
if (this.data.type && !this.data.type.includes('library')){
|
if (this.data.type && !this.data.type.includes("library")){
|
||||||
// please keep using vars here
|
// please keep using vars here
|
||||||
var params = {"fields[albums]": "inLibrary","relate" : "library"}
|
var params = {"fields[playlists]": "inLibrary","fields[albums]": "inLibrary","relate" : "library"}
|
||||||
var res = await app.mkapi(this.data.attributes.playParams.kind ?? this.data.type, false , this.data.attributes.playParams.id ?? this.data.id, params);
|
var res = await app.mkapi(this.data.attributes.playParams.kind ?? this.data.type, this.data.attributes.playParams.isLibrary ?? false , this.data.attributes.playParams.id ?? this.data.id, params);
|
||||||
this.inLibrary = (res && res.attributes && res.attributes.inLibrary) ? res.attributes.inLibrary : false} else {this.inLibrary = true}
|
this.inLibrary = (res && res.attributes && res.attributes.inLibrary) ? res.attributes.inLibrary : false
|
||||||
|
console.log(res)
|
||||||
|
} else {this.inLibrary = true}
|
||||||
},
|
},
|
||||||
editPlaylist() {
|
editPlaylist() {
|
||||||
app.editPlaylist(this.data.id, this.data.attributes.name);
|
app.editPlaylist(this.data.id, this.data.attributes.name);
|
||||||
|
@ -123,10 +125,16 @@
|
||||||
app.mk.addToLibrary(id)
|
app.mk.addToLibrary(id)
|
||||||
this.inLibrary = true
|
this.inLibrary = true
|
||||||
},
|
},
|
||||||
removeFromLibrary(id) {
|
async removeFromLibrary(id) {
|
||||||
|
var params = {"fields[somgs]": "inLibrary","fields[albums]": "inLibrary","relate" : "library"}
|
||||||
|
var id = this.data.id ?? this.data.attributes.playParams.id
|
||||||
|
var res = await app.mkapi(this.data.attributes.playParams.kind ?? this.data.type, this.data.attributes.playParams.isLibrary ?? false , this.data.attributes.playParams.id ?? this.data.id, params);
|
||||||
|
if (res && res.relationships && res.relationships.library && res.relationships.library.data && res.relationships.library.data.length > 0) {
|
||||||
|
id = res.relationships.library.data[0].id
|
||||||
|
}
|
||||||
let kind = this.data.attributes.playParams.kind ?? this.data.type ?? '';
|
let kind = this.data.attributes.playParams.kind ?? this.data.type ?? '';
|
||||||
var truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
var truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||||
app.mk.api.library.remove({[truekind]: this.data.id ?? this.data.attributes.playParams.id })
|
app.mk.api.library.remove({[truekind]: id })
|
||||||
this.inLibrary = false
|
this.inLibrary = false
|
||||||
},
|
},
|
||||||
editPlaylistName() {
|
editPlaylistName() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue