diff --git a/server/app/api.py b/server/app/api.py index d1e8aa5b..50be6298 100644 --- a/server/app/api.py +++ b/server/app/api.py @@ -314,8 +314,9 @@ def getFolderTree(folder: str = None): song['artists'] = song['artists'].split(', ') or None except: pass - - song['image'] = img_path + song['image'] + if song['image'] is not None: + print(song['image']) + song['image'] = img_path + song['image'] return {"files": remove_duplicates(songs), "folders": sorted(folders, key=lambda i: i['name'])} diff --git a/src/assets/images/null.webp b/src/assets/images/null.webp index 985be000..94dd613c 100644 Binary files a/src/assets/images/null.webp and b/src/assets/images/null.webp differ diff --git a/src/components/FolderView/SearchBox.vue b/src/components/FolderView/Header.vue similarity index 100% rename from src/components/FolderView/SearchBox.vue rename to src/components/FolderView/Header.vue diff --git a/src/components/FolderView/SongList.vue b/src/components/FolderView/SongList.vue index e7c0205c..16ab6db6 100644 --- a/src/components/FolderView/SongList.vue +++ b/src/components/FolderView/SongList.vue @@ -82,23 +82,16 @@ export default { const current = ref(perks.current); const search_query = ref(state.search_query); - const updateQueue = async (song) => { - if (state.queue.value[0]._id.$oid !== song_list.value[0]._id.$oid) { - const new_queue = song_list.value; - localStorage.setItem("queue", JSON.stringify(new_queue)); - state.queue.value = new_queue; - } - - state.current.value = song; - localStorage.setItem("current", JSON.stringify(song)); - }; + function updateQueue(song){ + perks.updateQueue(song) + } const searchSongs = computed(() => { const songs = []; if (search_query.value.length > 2) { state.loading.value = true; - + for (let i = 0; i < song_list.value.length; i++) { if ( song_list.value[i].title @@ -162,7 +155,7 @@ export default { width: 3rem; height: 3rem; margin-right: 1rem; - background-image: url(../../assets/icons/file.svg); + background-image: url(../../assets/images/null.webp); display: grid; place-items: center; } diff --git a/src/components/SongItem.vue b/src/components/SongItem.vue index b87bee50..030487e9 100644 --- a/src/components/SongItem.vue +++ b/src/components/SongItem.vue @@ -3,7 +3,7 @@
import perks from "@/composables/perks.js"; import state from "@/composables/state.js"; -import audio from "@/composables/playAudio.js" export default { props: ["song", "current", "songTitleWidth", "minWidth"], @@ -69,7 +68,6 @@ export default { putCommas: perks.putCommas, emitUpdate, is_playing: state.is_playing, - playAudio: audio.playAudio }; }, }; diff --git a/src/composables/perks.js b/src/composables/perks.js index 8278ddaa..e0960dea 100644 --- a/src/composables/perks.js +++ b/src/composables/perks.js @@ -80,6 +80,19 @@ const readQueue = () => { } }; +const updateQueue = async (song) => { + playAudio.playAudio(song.filepath) + + if (state.queue.value[0]._id.$oid !== state.song_list.value[0]._id.$oid) { + const new_queue = state.song_list.value; + localStorage.setItem("queue", JSON.stringify(new_queue)); + state.queue.value = new_queue; + } + + state.current.value = song; + localStorage.setItem("current", JSON.stringify(song)); +}; + function focusCurrent() { const elem = document.getElementsByClassName("currentInQueue")[0]; @@ -92,21 +105,21 @@ function focusCurrent() { } } -function getElem(identifier, type){ - switch(type){ +function getElem(identifier, type) { + switch (type) { case "class": { - return document.getElementsByClassName(identifier)[0] + return document.getElementsByClassName(identifier)[0]; } case "id": { - return document.getElementById(identifier) + return document.getElementById(identifier); } } } function focusSearchBox() { - const elem = getElem('search', 'id') + const elem = getElem("search", "id"); - elem.focus() + elem.focus(); } setTimeout(() => { @@ -135,7 +148,7 @@ window.addEventListener("keydown", (e) => { setTimeout(() => { key_down_fired = false; }, 1000); - + playAudio.playNext(); } } @@ -151,7 +164,6 @@ window.addEventListener("keydown", (e) => { setTimeout(() => { key_down_fired = false; }, 1000); - } } @@ -174,7 +186,7 @@ window.addEventListener("keydown", (e) => { if (!key_down_fired) { if (!ctrlKey) return; e.preventDefault(); - focusSearchBox() + focusSearchBox(); key_down_fired = true; } @@ -190,6 +202,7 @@ export default { putCommas, readQueue, focusCurrent, + updateQueue, current, queue, next, diff --git a/src/composables/state.js b/src/composables/state.js index d4b0318a..61b7b94b 100644 --- a/src/composables/state.js +++ b/src/composables/state.js @@ -12,6 +12,9 @@ const queue = ref([ }, ]); +const song_list = ref([]) +const folder_list = ref([]) + const current = ref({ title: "Nothing played yet", artists: ["... blah blah blah"], @@ -41,6 +44,8 @@ const search_artists = ref([]); export default { search_query, queue, + song_list, + folder_list, current, prev, filters, diff --git a/src/views/FolderView.vue b/src/views/FolderView.vue index d022684a..1c36fbce 100644 --- a/src/views/FolderView.vue +++ b/src/views/FolderView.vue @@ -1,7 +1,7 @@