🔨 Finish add

This commit is contained in:
SebClem 2022-06-23 18:26:54 +02:00
parent b5707a7bca
commit 9a8f1b112a
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
2 changed files with 40 additions and 2 deletions

View File

@ -164,7 +164,6 @@
variant="outlined"
label="Url"
hide-details="auto"
@change="add"
color="primary"
autofocus
:loading="urlLoading"
@ -462,6 +461,19 @@ function stop() {
function add() {
if (url.value) {
urlLoading.value = true;
audioService
.add(properties.guild.id, url.value)
.then((value) => {
if (value) {
status.value = value.data;
}
urlLoading.value = false;
urlPopup.value = false;
url.value = "";
})
.catch(() => {
urlLoading.value = false;
});
}
}

View File

@ -169,4 +169,30 @@ function stop(guildId: string) {
});
}
export { getAudioStatus, connect, disconnect, resume, pause, skip, stop };
function add(guildId: string, url: string) {
const userStore = useUserStore();
return axios
.post<Status>(
`/audio/${guildId}/add`,
{
url: url,
},
{
headers: {
authorization: `Bearer ${userStore.token}`,
},
}
)
.catch((reason) => {
console.error(`Fail to add track to playlist !`);
console.log(reason);
const eventQueuStore = useEventQueuStore();
eventQueuStore.push({
uuid: undefined,
type: "error",
text: "Fail to add track to playlist !",
});
});
}
export { getAudioStatus, connect, disconnect, resume, pause, skip, stop, add };