mirror of
https://github.com/smittix/intercept.git
synced 2026-04-30 01:29:59 -07:00
Fix duplicate aircraft cards in console output
Now updates existing cards instead of creating duplicates when receiving updates for the same ICAO. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7897,8 +7897,16 @@
|
||||
const placeholder = output.querySelector('.placeholder');
|
||||
if (placeholder) placeholder.remove();
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = 'aircraft-card';
|
||||
// Check if card for this ICAO already exists
|
||||
let card = output.querySelector(`[data-icao="${aircraft.icao}"]`);
|
||||
const isNew = !card;
|
||||
|
||||
if (isNew) {
|
||||
card = document.createElement('div');
|
||||
card.className = 'aircraft-card';
|
||||
card.setAttribute('data-icao', aircraft.icao);
|
||||
}
|
||||
|
||||
card.innerHTML = `
|
||||
<div class="aircraft-icon" style="--heading: ${aircraft.heading || 0}deg;">✈️</div>
|
||||
<div class="aircraft-info">
|
||||
@@ -7909,11 +7917,13 @@
|
||||
<div class="aircraft-data">Heading: <span>${aircraft.heading ? aircraft.heading + '°' : 'N/A'}</span></div>
|
||||
</div>
|
||||
`;
|
||||
output.insertBefore(card, output.firstChild);
|
||||
|
||||
// Limit cards
|
||||
while (output.children.length > 50) {
|
||||
output.removeChild(output.lastChild);
|
||||
if (isNew) {
|
||||
output.insertBefore(card, output.firstChild);
|
||||
// Limit cards
|
||||
while (output.children.length > 50) {
|
||||
output.removeChild(output.lastChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user