mirror of
https://github.com/open-webui/open-webui.git
synced 2026-04-25 17:15:16 +02:00
fix: Fix memory leaking in create model page (#21966)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<script>
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
<script lang="ts">
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { goto } from '$app/navigation';
|
||||
import { config, models, settings } from '$lib/stores';
|
||||
@@ -61,8 +60,8 @@
|
||||
|
||||
let model = null;
|
||||
|
||||
onMount(async () => {
|
||||
window.addEventListener('message', async (event) => {
|
||||
onMount(() => {
|
||||
const handleMessageEvent = async (event: MessageEvent) => {
|
||||
if (
|
||||
!['https://openwebui.com', 'https://www.openwebui.com', 'http://localhost:9999'].includes(
|
||||
event.origin
|
||||
@@ -82,7 +81,8 @@
|
||||
} catch (e) {
|
||||
console.error('Failed to parse message data:', e);
|
||||
}
|
||||
});
|
||||
}
|
||||
window.addEventListener('message', handleMessageEvent);
|
||||
|
||||
if (window.opener ?? false) {
|
||||
window.opener.postMessage('loaded', '*');
|
||||
@@ -92,6 +92,10 @@
|
||||
model = JSON.parse(sessionStorage.model);
|
||||
sessionStorage.removeItem('model');
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('message', handleMessageEvent);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user