Skip to content

Commit b38ac92

Browse files
committed
Fix power off phosphors for viewer count
1 parent 204ad6b commit b38ac92

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/components/ChannelDisplay.astro

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,28 @@ const isAiring = Boolean(startTime && endTime) && program !== null;
280280
history: number[] | undefined,
281281
currentCount: number,
282282
): void {
283+
// If we have history from the API, use it
283284
if (history && Array.isArray(history) && history.length > 0) {
284-
// Use the history from the API if available
285285
this.visitorHistory = history;
286286
} else {
287+
// If no history provided, try to get initial data from the dataset
288+
const initialData = this.dataset.initialVisitors;
289+
if (initialData) {
290+
try {
291+
const parsed = JSON.parse(initialData);
292+
if (
293+
parsed.history &&
294+
Array.isArray(parsed.history) &&
295+
parsed.history.length > 0
296+
) {
297+
this.visitorHistory = parsed.history;
298+
return;
299+
}
300+
} catch (error) {
301+
console.error("Failed to parse initial visitor data:", error);
302+
}
303+
}
304+
287305
// Fallback to updating with just the current count
288306
this.visitorHistory = [...this.visitorHistory.slice(1), currentCount];
289307
}
@@ -608,15 +626,9 @@ const isAiring = Boolean(startTime && endTime) && program !== null;
608626
}
609627

610628
#visitors {
611-
color: var(--phosphor-inactive);
612629
display: flex;
613630
align-items: center;
614631
gap: 0.5em;
615-
616-
&[data-active="true"] {
617-
color: var(--phosphor-active);
618-
text-shadow: var(--phosphor-glow);
619-
}
620632
}
621633

622634
.visitor-trend {
@@ -666,10 +678,10 @@ const isAiring = Boolean(startTime && endTime) && program !== null;
666678
#visitors[data-active="true"] {
667679
.visitor-trend rect {
668680
filter: drop-shadow(
669-
0 0 2px color-mix(in srgb, currentColor 50%, transparent)
681+
0 0 2px color-mix(in srgb, currentColor 30%, transparent)
670682
)
671-
drop-shadow(0 0 4px color-mix(in srgb, currentColor 40%, transparent))
672-
drop-shadow(0 0 8px color-mix(in srgb, currentColor 30%, transparent));
683+
drop-shadow(0 0 4px color-mix(in srgb, currentColor 20%, transparent))
684+
drop-shadow(0 0 8px color-mix(in srgb, currentColor 15%, transparent));
673685
}
674686
}
675687
</style>

0 commit comments

Comments
 (0)