improvements to isInLibrary

This commit is contained in:
booploops 2021-12-07 13:35:30 -08:00
parent 6282913b90
commit a29ab36a58
2 changed files with 13 additions and 5 deletions

View file

@ -346,11 +346,11 @@ const app = new Vue({
return await this.mkapi(method, library, term, params, params2, attempts + 1) return await this.mkapi(method, library, term, params, params2, attempts + 1)
} }
}, },
async getLibrarySongsFull() { async getLibrarySongsFull(force = false) {
let self = this let self = this
let library = [] let library = []
let downloaded = null; let downloaded = null;
if (this.library.songs.downloadState == 2 || this.library.songs.downloadState == 1) { if ((this.library.songs.downloadState == 2 || this.library.songs.downloadState == 1) && !force) {
return return
} }
if(localStorage.getItem("librarySongs") != null) { if(localStorage.getItem("librarySongs") != null) {
@ -855,9 +855,17 @@ const app = new Vue({
self.search.results = results self.search.results = results
}) })
}, },
isInLibrary(id) { isInLibrary(playParams) {
let self = this let self = this
let id = ""
// ugly code to check if current playback item is in library // ugly code to check if current playback item is in library
if(playParams.catalogId) {
id = playParams.catalogId
}else if(playParams.id) {
id = playParams.id
}else if(playParams.isLibrary) {
return true
}
var found = this.library.songs.listing.filter((item)=>{ var found = this.library.songs.listing.filter((item)=>{
if(item["attributes"]){ if(item["attributes"]){
if(item["attributes"]["playParams"] && (item["attributes"]["playParams"]["catalogId"] == id)){ if(item["attributes"]["playParams"] && (item["attributes"]["playParams"]["catalogId"] == id)){

View file

@ -75,8 +75,8 @@
:max="mk.currentPlaybackDuration" :value="playerLCD.playbackDuration"> :max="mk.currentPlaybackDuration" :value="playerLCD.playbackDuration">
</div> </div>
</div> </div>
<template v-if="mk.nowPlayingItem['attributes']['playParams']['id']"> <template v-if="mk.nowPlayingItem['attributes']['playParams']">
<div class="actions" v-if="isInLibrary(mk.nowPlayingItem['attributes']['playParams']['id'])">❤️</div> <div class="actions" v-if="isInLibrary(mk.nowPlayingItem['attributes']['playParams'])">❤️</div>
<div class="actions" v-else>🖤</div> <div class="actions" v-else>🖤</div>
</template> </template>