From c213b48090fd1e1cb1c09bca789073d59218556f Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 4 Nov 2024 19:52:52 +0100 Subject: [PATCH] ui fixes --- src/routes/hedge-funds/[slug]/+page.svelte | 30 +++++++++---------- src/routes/options-flow/+page.svelte | 35 ++++++++++++++++++---- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/routes/hedge-funds/[slug]/+page.svelte b/src/routes/hedge-funds/[slug]/+page.svelte index 6bb90c74..b40088c9 100644 --- a/src/routes/hedge-funds/[slug]/+page.svelte +++ b/src/routes/hedge-funds/[slug]/+page.svelte @@ -27,43 +27,43 @@ let path; switch (sector) { case "Financials": - path = "financial-sector"; + path = "financial"; break; case "Healthcare": - path = "healthcare-sector"; + path = "healthcare"; break; case "Information Technology": - path = "technology-sector"; + path = "technology"; break; case "Technology": - path = "technology-sector"; + path = "technology"; break; case "Financial Services": - path = "financial-sector"; + path = "financial"; break; case "Industrials": - path = "industrials-sector"; + path = "industrials"; break; case "Energy": - path = "energy-sector"; + path = "energy"; break; case "Utilities": - path = "utilities-sector"; + path = "utilities"; break; case "Consumer Cyclical": - path = "consumer-cyclical-sector"; + path = "consumer-cyclical"; break; case "Real Estate": - path = "real-estate-sector"; + path = "real-estate"; break; case "Basic Materials": - path = "basic-materials-sector"; + path = "basic-materials"; break; case "Communication Services": - path = "communication-services-sector"; + path = "communication-services"; break; case "Consumer Defensive": - path = "consumer-defensive-sector"; + path = "consumer-defensive"; break; default: // Handle default case if needed @@ -693,13 +693,13 @@ {#each rawData?.topSectors as item} - {#each Object.entries(item) as [name, value]} + {#each Object?.entries(item) as [name, value]} {name} diff --git a/src/routes/options-flow/+page.svelte b/src/routes/options-flow/+page.svelte index cfb8be6f..ecc2291e 100644 --- a/src/routes/options-flow/+page.svelte +++ b/src/routes/options-flow/+page.svelte @@ -363,8 +363,8 @@ let audio; let muted = false; - let newIncomingData = false; - let previousCallVolume = 0; //This is needed to play the sound only if it changes. + let newData = []; + let previousVolume = 0; //This is needed to play the sound only if it changes. let notFound = false; let isLoaded = false; let mode = $isOpen === true ? true : false; @@ -457,7 +457,7 @@ function sendMessage(message) { */ async function websocketRealtimeData() { - let newData = []; + newData = []; try { socket = new WebSocket(data?.wsURL + "/options-flow-reader"); /* @@ -468,7 +468,7 @@ function sendMessage(message) { */ socket.addEventListener("message", (event) => { - previousCallVolume = displayCallVolume ?? 0; + previousVolume = displayCallVolume + displayPutVolume || 0; if (mode === true) { try { newData = JSON.parse(event.data) ?? []; @@ -479,7 +479,13 @@ function sendMessage(message) { if (newData?.length > rawData?.length) { rawData = newData; displayedData = rawData; - if (!muted) { + + newData = []; + if ( + !muted && + ruleOfList?.length === 0 && + filterQuery?.length === 0 + ) { audio?.play(); } } @@ -804,7 +810,7 @@ function sendMessage(message) { ruleToUpdate.value = valueMappings[ruleToUpdate.name]; ruleToUpdate.condition = ruleCondition[ruleToUpdate.name]; ruleOfList = [...ruleOfList]; - shouldLoadWorker.set(true); + //shouldLoadWorker.set(true); } } } @@ -928,6 +934,23 @@ function sendMessage(message) { // Sort using the appropriate comparison function displayedData = originalData.sort(compareFunctions[key]); } + + $: { + if ( + previousVolume !== displayCallVolume + displayPutVolume && + typeof window !== "undefined" && + newData?.length !== 0 + ) { + if ( + !muted && + mode && + (ruleOfList?.length !== 0 || filterQuery?.length !== 0) + ) { + audio?.play(); + console.log("sound for filtered list"); + } + } + }