bugfixing websocket

This commit is contained in:
MuslemRahimi 2024-12-10 16:39:56 +01:00
parent e166bb7d19
commit 1af24ec844
2 changed files with 10 additions and 9 deletions

View File

@ -409,12 +409,12 @@
$: stockList = [...stockList]; $: stockList = [...stockList];
onMount(async () => { $: if ($isOpen) {
// Initialize the download worker if not already done websocketRealtimeData();
if ($isOpen) { console.log("WebSocket restarted");
await websocketRealtimeData();
console.log("WebSocket restarted due to watchlist changes");
} }
onMount(async () => {
try { try {
const savedRules = localStorage?.getItem(pagePathName); const savedRules = localStorage?.getItem(pagePathName);

View File

@ -580,6 +580,11 @@
} }
} }
$: if ($isOpen) {
websocketRealtimeData();
console.log("WebSocket restarted");
}
onMount(async () => { onMount(async () => {
try { try {
const savedRules = localStorage?.getItem("watchlist-ruleOfList"); const savedRules = localStorage?.getItem("watchlist-ruleOfList");
@ -648,10 +653,6 @@
console.log(e); console.log(e);
} }
if ($isOpen) {
await websocketRealtimeData();
}
window.addEventListener("scroll", handleScroll); window.addEventListener("scroll", handleScroll);
return () => { return () => {
window.removeEventListener("scroll", handleScroll); window.removeEventListener("scroll", handleScroll);