mirror of
https://github.com/open-webui/open-webui.git
synced 2025-03-17 21:32:42 +01:00
fix: chat event handler not being registered on sign in
This commit is contained in:
parent
80f5573cf3
commit
7e65f7fa4d
@ -5,7 +5,7 @@
|
||||
import { flyAndScale } from '$lib/utils/transitions';
|
||||
import { goto } from '$app/navigation';
|
||||
import ArchiveBox from '$lib/components/icons/ArchiveBox.svelte';
|
||||
import { showSettings, activeUserIds, USAGE_POOL, mobile, showSidebar } from '$lib/stores';
|
||||
import { showSettings, activeUserIds, USAGE_POOL, mobile, showSidebar, user } from '$lib/stores';
|
||||
import { fade, slide } from 'svelte/transition';
|
||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||
import { userSignOut } from '$lib/apis/auths';
|
||||
@ -157,8 +157,11 @@
|
||||
class="flex rounded-md py-2 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition"
|
||||
on:click={async () => {
|
||||
await userSignOut();
|
||||
user.set(null);
|
||||
|
||||
localStorage.removeItem('token');
|
||||
location.href = '/auth';
|
||||
|
||||
show = false;
|
||||
}}
|
||||
>
|
||||
|
@ -37,7 +37,7 @@ const createIsLoadingStore = (i18n: i18nType) => {
|
||||
return isLoading;
|
||||
};
|
||||
|
||||
export const initI18n = (defaultLocale: string | undefined) => {
|
||||
export const initI18n = (defaultLocale?: string | undefined) => {
|
||||
let detectionOrder = defaultLocale
|
||||
? ['querystring', 'localStorage']
|
||||
: ['querystring', 'localStorage', 'navigator'];
|
||||
|
@ -220,6 +220,8 @@
|
||||
const type = event?.data?.type ?? null;
|
||||
const data = event?.data?.data ?? null;
|
||||
|
||||
console.log('chatEventHandler', event);
|
||||
|
||||
if ((event.chat_id !== $chatId && !$temporaryChatEnabled) || isFocused) {
|
||||
if (type === 'chat:completion') {
|
||||
const { done, content, title } = data;
|
||||
@ -443,6 +445,7 @@
|
||||
theme.set(localStorage.theme);
|
||||
|
||||
mobile.set(window.innerWidth < BREAKPOINT);
|
||||
|
||||
const onResize = () => {
|
||||
if (window.innerWidth < BREAKPOINT) {
|
||||
mobile.set(true);
|
||||
@ -450,9 +453,18 @@
|
||||
mobile.set(false);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('resize', onResize);
|
||||
|
||||
user.subscribe((value) => {
|
||||
if (value) {
|
||||
$socket?.off('chat-events', chatEventHandler);
|
||||
$socket?.off('channel-events', channelEventHandler);
|
||||
|
||||
$socket?.on('chat-events', chatEventHandler);
|
||||
$socket?.on('channel-events', channelEventHandler);
|
||||
}
|
||||
});
|
||||
|
||||
let backendConfig = null;
|
||||
try {
|
||||
backendConfig = await getBackendConfig();
|
||||
@ -494,9 +506,6 @@
|
||||
// Save Session User to Store
|
||||
$socket.emit('user-join', { auth: { token: sessionUser.token } });
|
||||
|
||||
$socket?.on('chat-events', chatEventHandler);
|
||||
$socket?.on('channel-events', channelEventHandler);
|
||||
|
||||
await user.set(sessionUser);
|
||||
await config.set(await getBackendConfig());
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user