client: fix sending multiple requests

on songlist click
This commit is contained in:
geoffrey45
2021-12-22 09:22:22 +03:00
parent 36999d8061
commit 81c8ae8629
7 changed files with 151 additions and 47 deletions
+48 -1
View File
@@ -1,3 +1,25 @@
import { ref } from "@vue/reactivity";
const current = ref({
title: "Nothing played yet",
artists: ["... blah blah blah"],
});
const next = ref({
title: "Next song shows here",
artists: ["... blah blah blah"],
});
const queue = ref([
{
title: "Nothing played yet",
artists: ["... blah blah blah"],
_id: {
$oid: ""
}
}
]);
const putCommas = (artists) => {
let result = [];
@@ -12,4 +34,29 @@ const putCommas = (artists) => {
return result;
};
export default putCommas;
const doThat = (songs, current) => {
queue.value = songs;
current.value = current;
console.log(queue.value);
};
const readQueue = () => {
const prev_queue = JSON.parse(localStorage.getItem("queue"));
const last_played = JSON.parse(localStorage.getItem("current"));
const next_ = JSON.parse(localStorage.getItem("next"));
if (last_played){
current.value = last_played;
}
if (prev_queue){
queue.value = prev_queue;
}
if (next_){
next.value = next_;
}
}
export default { putCommas, doThat, readQueue, current, queue, next };