Login still a bit buggy but working...
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { DocumentStore } from '@/stores/documents'
|
||||
import { useDocumentStore } from '@/stores/documents'
|
||||
import createWebSocket from './WS'
|
||||
|
||||
export type FUID = string
|
||||
|
||||
@@ -63,6 +64,19 @@ export class DocumentHandler {
|
||||
|
||||
handleWebSocketMessage(event: MessageEvent) {
|
||||
const msg = JSON.parse(event.data)
|
||||
if ("error" in msg) {
|
||||
if (msg.error.code === 401) {
|
||||
this.store.user.isLoggedIn = false
|
||||
this.store.user.isOpenLoginModal = true
|
||||
} else {
|
||||
this.store.error = msg.error.message
|
||||
}
|
||||
// The server closes the websocket after errors, so we need to reopen it
|
||||
setTimeout(
|
||||
() => { this.store.wsWatch = createWebSocket(url_document_watch_ws, this.handleWebSocketMessage)},
|
||||
1000
|
||||
)
|
||||
}
|
||||
switch (true) {
|
||||
case !!msg.root:
|
||||
this.handleRootMessage(msg)
|
||||
|
||||
Reference in New Issue
Block a user