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