fix(ItemCard): clear local storage queues and refresh background on pack toggle

This commit is contained in:
alexsparkes
2026-02-03 20:31:38 +00:00
parent fb9787642b
commit ede1615ab8

View File

@@ -103,9 +103,21 @@ function ItemCard({
onTogglePack(packId, newState);
}
// Emit refresh event for quotes only (background will update on next interval)
// Clear queue when toggling pack state to prevent stale content
if (item.type === 'quotes') {
// Clear quote queue
localStorage.removeItem('quoteQueue');
localStorage.removeItem('currentQuote');
EventBus.emit('refresh', 'quote');
} else if (item.type === 'photos') {
// Clear photo pack queue
localStorage.removeItem('photoPackQueue');
localStorage.removeItem('currentPhoto');
// Only refresh if background is currently blank/black to avoid jarring changes
const backgroundImage = document.getElementById('backgroundImage');
if (!backgroundImage || !backgroundImage.style.backgroundImage) {
EventBus.emit('refresh', 'background');
}
}
};