refactor: reload config on websocket connection.
This commit is contained in:
parent
d8ccbe00fa
commit
651aa14882
3 changed files with 8 additions and 20 deletions
|
|
@ -1,13 +1,16 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from app.library.Events import EventBus, Events
|
||||||
from app.library.router import RouteType, route
|
from app.library.router import RouteType, route
|
||||||
|
|
||||||
LOG: logging.Logger = logging.getLogger(__name__)
|
LOG: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@route(RouteType.SOCKET, "connect", "socket_connect")
|
@route(RouteType.SOCKET, "connect", "socket_connect")
|
||||||
async def connect(sid: str):
|
async def connect(notify: EventBus, sid: str):
|
||||||
pass
|
notify.emit(
|
||||||
|
Events.CONNECTED, data={"sid": sid}, title="Client connected", message=f"Client '{sid}' connected.", to=sid
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@route(RouteType.SOCKET, "disconnect", "socket_disconnect")
|
@route(RouteType.SOCKET, "disconnect", "socket_disconnect")
|
||||||
|
|
|
||||||
|
|
@ -264,20 +264,9 @@ export const useSocketStore = defineStore('socket', () => {
|
||||||
|
|
||||||
on('connect', () => config.loadConfig(false))
|
on('connect', () => config.loadConfig(false))
|
||||||
|
|
||||||
on('connected', (data: WSEP['connected']) => {
|
on('connected', () => {
|
||||||
if (!data?.data) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.data.folders) {
|
|
||||||
config.add('folders', data.data.folders)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('number' === typeof data.data.history_count) {
|
|
||||||
stateStore.setHistoryCount(data.data.history_count)
|
|
||||||
}
|
|
||||||
|
|
||||||
error.value = null
|
error.value = null
|
||||||
|
config.loadConfig(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
on('item_added', (data: WSEP['item_added']) => {
|
on('item_added', (data: WSEP['item_added']) => {
|
||||||
|
|
|
||||||
6
ui/app/types/sockets.d.ts
vendored
6
ui/app/types/sockets.d.ts
vendored
|
|
@ -20,11 +20,7 @@ export type WSEP = {
|
||||||
connect: null
|
connect: null
|
||||||
disconnect: null
|
disconnect: null
|
||||||
connect_error: { message?: string }
|
connect_error: { message?: string }
|
||||||
connected: EventPayload<{
|
connected: EventPayload<{ sid: string }>
|
||||||
folders?: string[]
|
|
||||||
history_count?: number
|
|
||||||
queue?: Record<string, StoreItem>
|
|
||||||
}>
|
|
||||||
item_added: EventPayload<StoreItem>
|
item_added: EventPayload<StoreItem>
|
||||||
item_updated: EventPayload<StoreItem>
|
item_updated: EventPayload<StoreItem>
|
||||||
item_cancelled: EventPayload<StoreItem>
|
item_cancelled: EventPayload<StoreItem>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue