mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
client: implement queuing
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
const car = () => {
|
||||
return;
|
||||
};
|
||||
|
||||
export default car;
|
||||
@@ -12,13 +12,13 @@ const getData = async (path, last_id) => {
|
||||
if (last_id) {
|
||||
url = `${folders_uri}/f/${encoded_path}::${last_id}`;
|
||||
} else {
|
||||
url = url = `${folders_uri}/f/${encoded_path}`;
|
||||
url = url = `${folders_uri}/f/${encoded_path}::None`;
|
||||
}
|
||||
|
||||
const res = await fetch(url);
|
||||
|
||||
if (!res.ok) {
|
||||
const message = `An erro has occured: ${res.status}`;
|
||||
const message = `An error has occured: ${res.status}`;
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
const url = "http://127.0.0.1:9876/get/queue";
|
||||
|
||||
const getQueue = async (type, id) => {
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
type: type,
|
||||
id: id,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const message = `An error has occured: ${res.status}`;
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
localStorage.setItem("queue", JSON.stringify(data.songs));
|
||||
|
||||
return data.songs;
|
||||
};
|
||||
|
||||
export default getQueue;
|
||||
@@ -0,0 +1,15 @@
|
||||
const putCommas = (artists) => {
|
||||
let result = [];
|
||||
|
||||
artists.forEach((i, index, artists) => {
|
||||
if (index !== artists.length - 1) {
|
||||
result.push(i + ", ");
|
||||
} else {
|
||||
result.push(i);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
export default putCommas;
|
||||
Reference in New Issue
Block a user