Login still a bit buggy but working...

This commit is contained in:
Leo Vasanko
2023-11-03 21:19:26 +00:00
parent 119aba2b3c
commit b759d8324c
8 changed files with 66 additions and 64 deletions

View File

@@ -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)