Fixed search and websocket debug

This commit is contained in:
RemixDev 2021-03-01 00:01:50 +01:00
parent 632ca94975
commit c6a2f35fbf
No known key found for this signature in database
GPG Key ID: B33962B465BDB51C
5 changed files with 16 additions and 22 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,15 +1,12 @@
import { ref } from '@vue/composition-api'
import { socket } from '@/utils/socket'
import { get } from '@/utils/api'
const searchResult = ref({})
function performMainSearch(searchTerm) {
socket.emit('mainSearch', { term: searchTerm })
socket.on('mainSearch', data => {
get('mainSearch', { term: searchTerm })
.then(data => {
searchResult.value = data
socket.off('mainSearch')
})
}

View File

@ -1,20 +1,16 @@
import { ref } from '@vue/composition-api'
import { socket } from '@/utils/socket'
import { get } from '@/utils/api'
const result = ref({})
function performSearch({ term, type, start = 0, nb = 30 }) {
socket.emit('search', {
get('search', {
term,
type,
start,
nb
})
socket.on('search', data => {
}).then(data => {
result.value = data
socket.off('search')
})
}

View File

@ -1,4 +1,4 @@
import { socket } from '@/utils/socket'
import { get } from '@/utils/api'
/**
* @param {string} url
@ -7,7 +7,7 @@ import { socket } from '@/utils/socket'
export function sendAddToQueue(url, bitrate = null) {
if (!url) throw new Error('No URL given to sendAddToQueue function!')
socket.emit('addToQueue', { url, bitrate }, () => {})
get('addToQueue', { url, bitrate })
}
export function aggregateDownloadLinks(releases) {

View File

@ -13,6 +13,7 @@ class CustomSocket extends WebSocket {
on(key, callback) {
this.addEventListener('message', function(event){
let data = JSON.parse(event.data)
console.log(data)
if (data.key == key) callback(data.data)
})
}