add autoconnect prop.

This commit is contained in:
Miroslav Šedivý 2021-05-09 20:33:43 +02:00
parent 9d4740f7e5
commit 31cfacd1df

View File

@ -86,14 +86,17 @@
height: 0,
}
@Prop({ type: Boolean })
private readonly autoplay!: boolean
@Prop({ type: String })
private readonly server!: string
@Prop({ type: Boolean })
private readonly autologin!: boolean
@Prop({ type: String })
private readonly server!: string
@Prop({ type: Boolean })
private readonly autoconnect!: boolean
@Prop({ type: Boolean })
private readonly autoplay!: boolean
/////////////////////////////
// Public state
@ -171,7 +174,7 @@
// Public methods
/////////////////////////////
@Watch('server', { immediate: true })
public setUrl(url: string) {
public async setUrl(url: string) {
if (!url) {
url = location.href
}
@ -200,10 +203,12 @@
this.websocket.setToken(token)
}
this.api.session.whoami().then(() => {
Vue.set(this.state.connection, 'authenticated', true)
await this.api.session.whoami()
Vue.set(this.state.connection, 'authenticated', true)
if (this.autoconnect) {
this.websocket.connect()
})
}
}
}
@ -223,7 +228,10 @@
}
Vue.set(this.state.connection, 'authenticated', true)
this.websocket.connect()
if (this.autoconnect) {
this.websocket.connect()
}
}
public async logout() {