bugfixing websocket stock price shows zero

This commit is contained in:
MuslemRahimi 2024-07-12 19:23:57 +02:00
parent 2460f5920e
commit 2063b364e1
2 changed files with 3 additions and 3 deletions

View File

@ -267,7 +267,6 @@ async function websocketRealtimeData() {
$realtimePrice = typeof JSON.parse(data)?.bp !== 'undefined' ? JSON.parse(data)?.bp : null; $realtimePrice = typeof JSON.parse(data)?.bp !== 'undefined' ? JSON.parse(data)?.bp : null;
//console.log('Received message:', $realtimePrice); //console.log('Received message:', $realtimePrice);
if ($realtimePrice > previousRealtimePrice) { if ($realtimePrice > previousRealtimePrice) {
$priceIncrease = true; $priceIncrease = true;
previousRealtimePrice = $realtimePrice; previousRealtimePrice = $realtimePrice;

View File

@ -135,8 +135,9 @@ $: {
if ($stockTicker && typeof window !== 'undefined') // add a check to see if running on client-side if ($stockTicker && typeof window !== 'undefined') // add a check to see if running on client-side
{ {
if ($realtimePrice !== null) if ($realtimePrice !== null && $realtimePrice !== 0)
{ {
$realtimePrice = $realtimePrice !== 0 ? $realtimePrice : data?.getStockQuote?.price;
$currentPortfolioPrice = $realtimePrice; $currentPortfolioPrice = $realtimePrice;
} }
@ -770,7 +771,7 @@ function changeChartType() {
{#if $isCrosshairMoveActive } {#if $isCrosshairMoveActive }
{$stockTicker?.includes('.DE') || $stockTicker?.includes('.PA') || $stockTicker?.includes('.F') ? `${displayLegend?.close}` : ` $${displayLegend?.close}`} {$stockTicker?.includes('.DE') || $stockTicker?.includes('.PA') || $stockTicker?.includes('.F') ? `${displayLegend?.close}` : ` $${displayLegend?.close}`}
{:else if !$isCrosshairMoveActive && $realtimePrice !== null} {:else if !$isCrosshairMoveActive && $realtimePrice !== null}
{$stockTicker?.includes('.DE') || $stockTicker?.includes('.PA') || $stockTicker?.includes('.F') ? `${$realtimePrice}` : ` $${$realtimePrice}`} {$stockTicker?.includes('.DE') || $stockTicker?.includes('.PA') || $stockTicker?.includes('.F') ? `${$currentPortfolioPrice}` : ` $${$currentPortfolioPrice}`}
{:else} {:else}
{$stockTicker?.includes('.DE') || $stockTicker?.includes('.PA') || $stockTicker?.includes('.F') ? `${displayLegend?.close}` : ` $${displayLegend?.close}`} {$stockTicker?.includes('.DE') || $stockTicker?.includes('.PA') || $stockTicker?.includes('.F') ? `${displayLegend?.close}` : ` $${displayLegend?.close}`}