fix : 2nd screen message fixed

This commit is contained in:
karthik 2025-09-21 16:08:32 +05:30
parent 8bdd2e0b74
commit 71367b596d
3 changed files with 17 additions and 10 deletions

View File

@ -163,7 +163,7 @@ export class NavbarComponent implements OnInit, OnDestroy {
const newStatuses = new Map(statuses); const newStatuses = new Map(statuses);
const newStops: number[] = []; const newStops: number[] = [];
// Detect newly stopped races // Detect newly stopped races (same logic as before)
newStatuses.forEach((value, key) => { newStatuses.forEach((value, key) => {
const prev = this.stopbetStatuses.get(key); const prev = this.stopbetStatuses.get(key);
if (prev === 'N' || prev === undefined) { if (prev === 'N' || prev === undefined) {
@ -175,11 +175,13 @@ export class NavbarComponent implements OnInit, OnDestroy {
this.stopbetStatuses = newStatuses; this.stopbetStatuses = newStatuses;
// If there are new stops, display the message for 30 seconds // If there are new stops, display only the latest one (most recent)
if (newStops.length > 0) { if (newStops.length > 0) {
newStops.sort((a, b) => a - b); newStops.sort((a, b) => a - b); // sort ascending
this.stopMessage = newStops.map(r => `Race ${r} Stopped`).join(' - '); const latestStop = newStops[newStops.length - 1]; // pick the highest (latest) race number detected
// Sync new stop message to electron main if available this.stopMessage = `Race ${latestStop} Stopped`;
// Sync new single stop message to electron main if available
if ((window as any).electronAPI) { if ((window as any).electronAPI) {
try { try {
(window as any).electronAPI.syncStopMessage(this.stopMessage); (window as any).electronAPI.syncStopMessage(this.stopMessage);
@ -188,9 +190,11 @@ export class NavbarComponent implements OnInit, OnDestroy {
} }
} }
// Clear any existing timeout so message stays visible full duration
if (this.stopMessageTimeout) { if (this.stopMessageTimeout) {
clearTimeout(this.stopMessageTimeout); clearTimeout(this.stopMessageTimeout);
} }
// Keep message visible for 50 seconds (50000 ms) then clear
this.stopMessageTimeout = window.setTimeout(() => { this.stopMessageTimeout = window.setTimeout(() => {
this.stopMessage = ''; this.stopMessage = '';
this.stopMessageTimeout = null; this.stopMessageTimeout = null;

View File

@ -168,7 +168,7 @@ div[style*="background-color: black"] .custom-cell {
overflow: hidden; overflow: hidden;
box-sizing: border-box; box-sizing: border-box;
animation: scroll 20s linear infinite; /* Adjust duration for speed */ animation: scroll 20s linear infinite; /* Adjust duration for speed */
width: 100%; /* Ensure it takes full width */ width: 40%; /* Ensure it takes full width */
} }
@keyframes scroll { @keyframes scroll {

View File

@ -24,6 +24,7 @@ export class SharedTableComponent implements OnInit {
constructor(private websocketService: WebsocketService) {} constructor(private websocketService: WebsocketService) {}
ngOnInit() { ngOnInit() {
// (Websocket subscriptions are commented out by you — kept as-is)
// this.websocketService.message$.subscribe((msg) => { // this.websocketService.message$.subscribe((msg) => {
// this.message = msg; // this.message = msg;
// console.log('[SHARED TABLE] WebSocket message:', msg); // console.log('[SHARED TABLE] WebSocket message:', msg);
@ -34,12 +35,14 @@ export class SharedTableComponent implements OnInit {
// console.log('[SHARED TABLE] WebSocket connection status:', status); // console.log('[SHARED TABLE] WebSocket connection status:', status);
// }); // });
// Add this: Listen for stop message updates // Listen for stop message updates from electron main (only latest single message expected)
if (window.electronAPI) { if ((window as any).electronAPI && typeof (window as any).electronAPI.onUpdateStopMessage === 'function') {
window.electronAPI.onUpdateStopMessage((message: string) => { (window as any).electronAPI.onUpdateStopMessage((message: string) => {
this.stopMessage = message; this.stopMessage = message || '';
console.log('[SHARED TABLE] Received stop message:', message); console.log('[SHARED TABLE] Received stop message:', message);
}); });
} else {
console.warn('[SHARED TABLE] electronAPI.onUpdateStopMessage not available');
} }
} }
} }