This commit is contained in:
MuslemRahimi 2024-11-04 19:52:52 +01:00
parent 1e0c87b378
commit c213b48090
2 changed files with 44 additions and 21 deletions

View File

@ -27,43 +27,43 @@
let path; let path;
switch (sector) { switch (sector) {
case "Financials": case "Financials":
path = "financial-sector"; path = "financial";
break; break;
case "Healthcare": case "Healthcare":
path = "healthcare-sector"; path = "healthcare";
break; break;
case "Information Technology": case "Information Technology":
path = "technology-sector"; path = "technology";
break; break;
case "Technology": case "Technology":
path = "technology-sector"; path = "technology";
break; break;
case "Financial Services": case "Financial Services":
path = "financial-sector"; path = "financial";
break; break;
case "Industrials": case "Industrials":
path = "industrials-sector"; path = "industrials";
break; break;
case "Energy": case "Energy":
path = "energy-sector"; path = "energy";
break; break;
case "Utilities": case "Utilities":
path = "utilities-sector"; path = "utilities";
break; break;
case "Consumer Cyclical": case "Consumer Cyclical":
path = "consumer-cyclical-sector"; path = "consumer-cyclical";
break; break;
case "Real Estate": case "Real Estate":
path = "real-estate-sector"; path = "real-estate";
break; break;
case "Basic Materials": case "Basic Materials":
path = "basic-materials-sector"; path = "basic-materials";
break; break;
case "Communication Services": case "Communication Services":
path = "communication-services-sector"; path = "communication-services";
break; break;
case "Consumer Defensive": case "Consumer Defensive":
path = "consumer-defensive-sector"; path = "consumer-defensive";
break; break;
default: default:
// Handle default case if needed // Handle default case if needed
@ -693,13 +693,13 @@
</thead> </thead>
<tbody> <tbody>
{#each rawData?.topSectors as item} {#each rawData?.topSectors as item}
{#each Object.entries(item) as [name, value]} {#each Object?.entries(item) as [name, value]}
<tr <tr
class="text-white sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] bg-[#141417] border-b border-[#141417]" class="text-white sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] bg-[#141417] border-b border-[#141417]"
> >
<td class="text-[1rem] whitespace-nowrap"> <td class="text-[1rem] whitespace-nowrap">
<a <a
href={"/list/" + sectorSelector(name)} href={"/list/sector/" + sectorSelector(name)}
class="text-blue-400 sm:hover:text-white" class="text-blue-400 sm:hover:text-white"
> >
{name} {name}

View File

@ -363,8 +363,8 @@
let audio; let audio;
let muted = false; let muted = false;
let newIncomingData = false; let newData = [];
let previousCallVolume = 0; //This is needed to play the sound only if it changes. let previousVolume = 0; //This is needed to play the sound only if it changes.
let notFound = false; let notFound = false;
let isLoaded = false; let isLoaded = false;
let mode = $isOpen === true ? true : false; let mode = $isOpen === true ? true : false;
@ -457,7 +457,7 @@ function sendMessage(message) {
*/ */
async function websocketRealtimeData() { async function websocketRealtimeData() {
let newData = []; newData = [];
try { try {
socket = new WebSocket(data?.wsURL + "/options-flow-reader"); socket = new WebSocket(data?.wsURL + "/options-flow-reader");
/* /*
@ -468,7 +468,7 @@ function sendMessage(message) {
*/ */
socket.addEventListener("message", (event) => { socket.addEventListener("message", (event) => {
previousCallVolume = displayCallVolume ?? 0; previousVolume = displayCallVolume + displayPutVolume || 0;
if (mode === true) { if (mode === true) {
try { try {
newData = JSON.parse(event.data) ?? []; newData = JSON.parse(event.data) ?? [];
@ -479,7 +479,13 @@ function sendMessage(message) {
if (newData?.length > rawData?.length) { if (newData?.length > rawData?.length) {
rawData = newData; rawData = newData;
displayedData = rawData; displayedData = rawData;
if (!muted) {
newData = [];
if (
!muted &&
ruleOfList?.length === 0 &&
filterQuery?.length === 0
) {
audio?.play(); audio?.play();
} }
} }
@ -804,7 +810,7 @@ function sendMessage(message) {
ruleToUpdate.value = valueMappings[ruleToUpdate.name]; ruleToUpdate.value = valueMappings[ruleToUpdate.name];
ruleToUpdate.condition = ruleCondition[ruleToUpdate.name]; ruleToUpdate.condition = ruleCondition[ruleToUpdate.name];
ruleOfList = [...ruleOfList]; ruleOfList = [...ruleOfList];
shouldLoadWorker.set(true); //shouldLoadWorker.set(true);
} }
} }
} }
@ -928,6 +934,23 @@ function sendMessage(message) {
// Sort using the appropriate comparison function // Sort using the appropriate comparison function
displayedData = originalData.sort(compareFunctions[key]); 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");
}
}
}
</script> </script>
<svelte:head> <svelte:head>