mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-13 01:02:25 -06:00
refac
This commit is contained in:
@@ -29,6 +29,7 @@ export const MODEL_DOWNLOAD_POOL = writable({});
|
||||
export const mobile = writable(false);
|
||||
|
||||
export const socket: Writable<null | Socket> = writable(null);
|
||||
export const socketConnected: Writable<boolean> = writable(true);
|
||||
export const activeUserIds: Writable<null | string[]> = writable(null);
|
||||
export const activeChatIds: Writable<Set<string>> = writable(new Set());
|
||||
export const USAGE_POOL: Writable<null | string[]> = writable(null);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
WEBUI_DEPLOYMENT_ID,
|
||||
mobile,
|
||||
socket,
|
||||
socketConnected,
|
||||
chatId,
|
||||
chats,
|
||||
currentChatPage,
|
||||
@@ -127,8 +128,17 @@
|
||||
console.log('connect_error', err);
|
||||
});
|
||||
|
||||
let hasConnectedOnce = false;
|
||||
|
||||
_socket.on('connect', async () => {
|
||||
console.log('connected', _socket.id);
|
||||
|
||||
if (hasConnectedOnce) {
|
||||
socketConnected.set(true);
|
||||
toast.success($i18n.t('Reconnected'));
|
||||
}
|
||||
hasConnectedOnce = true;
|
||||
|
||||
const res = await getVersion(localStorage.token);
|
||||
|
||||
const deploymentId = res?.deployment_id ?? null;
|
||||
@@ -182,6 +192,8 @@
|
||||
|
||||
_socket.on('disconnect', (reason, details) => {
|
||||
console.log(`Socket ${_socket.id} disconnected due to ${reason}`);
|
||||
socketConnected.set(false);
|
||||
toast.warning($i18n.t('Connection lost. Reconnecting...'));
|
||||
|
||||
if (heartbeatInterval) {
|
||||
clearInterval(heartbeatInterval);
|
||||
|
||||
Reference in New Issue
Block a user