mirror of
https://github.com/koel/koel
synced 2025-02-17 13:58:28 +00:00
Make socket.init() async
This commit is contained in:
parent
9c39ef9e80
commit
75b0200633
2 changed files with 24 additions and 17 deletions
|
@ -77,7 +77,7 @@ export default {
|
|||
methods: {
|
||||
async init () {
|
||||
showOverlay()
|
||||
socket.init()
|
||||
await socket.init()
|
||||
|
||||
// Make the most important HTTP request to get all necessary data from the server.
|
||||
// Afterwards, init all mandatory stores and services.
|
||||
|
|
|
@ -7,24 +7,31 @@ export const socket = {
|
|||
pusher: null,
|
||||
channel: null,
|
||||
|
||||
init () {
|
||||
if (!process.env.PUSHER_APP_KEY) {
|
||||
return
|
||||
}
|
||||
async init () {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!process.env.PUSHER_APP_KEY) {
|
||||
return resolve()
|
||||
}
|
||||
|
||||
this.pusher = new Pusher(process.env.PUSHER_APP_KEY, {
|
||||
authEndpoint: '/api/broadcasting/auth',
|
||||
auth: {
|
||||
headers: {
|
||||
Authorization: `Bearer ${ls.get('jwt-token')}`
|
||||
}
|
||||
},
|
||||
cluster: process.env.PUSHER_APP_CLUSTER,
|
||||
encrypted: true
|
||||
this.pusher = new Pusher(process.env.PUSHER_APP_KEY, {
|
||||
authEndpoint: '/api/broadcasting/auth',
|
||||
auth: {
|
||||
headers: {
|
||||
Authorization: `Bearer ${ls.get('jwt-token')}`
|
||||
}
|
||||
},
|
||||
cluster: process.env.PUSHER_APP_CLUSTER,
|
||||
encrypted: true
|
||||
})
|
||||
|
||||
this.channel = this.pusher.subscribe('private-koel')
|
||||
this.channel.bind('pusher:subscription_succeeded', () => {
|
||||
return resolve()
|
||||
})
|
||||
this.channel.bind('pusher:subscription_error', () => {
|
||||
return resolve()
|
||||
})
|
||||
})
|
||||
this.channel = this.pusher.subscribe('private-koel')
|
||||
|
||||
return this
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue