handle some edge cases for socket lifecycle
This commit is contained in:
parent
43ddbfd652
commit
64cc748a9c
2 changed files with 8 additions and 0 deletions
|
|
@ -72,6 +72,9 @@ const GeneralTab = {
|
||||||
useLocalConfigStore().set({ path, value })
|
useLocalConfigStore().set({ path, value })
|
||||||
},
|
},
|
||||||
toggleStreaming(value) {
|
toggleStreaming(value) {
|
||||||
|
// Streaming is not available for the unauthenticated
|
||||||
|
if (!useOAuthStore().token) return
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
useStreamingStore().initSocket()
|
useStreamingStore().initSocket()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,9 @@ export const useStreamingStore = defineStore('streaming', {
|
||||||
stopSocket() {
|
stopSocket() {
|
||||||
this.socket.close()
|
this.socket.close()
|
||||||
this.state = WSConnectionStatus.CLOSED
|
this.state = WSConnectionStatus.CLOSED
|
||||||
|
this.retrying = false
|
||||||
|
this.retryMultiplier = 1
|
||||||
|
this.error = null
|
||||||
},
|
},
|
||||||
|
|
||||||
getSubArgs(stream) {
|
getSubArgs(stream) {
|
||||||
|
|
@ -229,6 +232,8 @@ export const useStreamingStore = defineStore('streaming', {
|
||||||
)
|
)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (this.retrying) return // retry aborted (i.e. due to logout)
|
||||||
|
|
||||||
this.initSocket()
|
this.initSocket()
|
||||||
}, retryTimeout(this.retryMultiplier))
|
}, retryTimeout(this.retryMultiplier))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue