Files
pulse/public/js/theme.js
T
rcourtman f53550fc6c fix: simplify frontend update channel switching for better UX
- Remove confusing "preview mode" - channels switch and save immediately
- Eliminate complex localStorage channel persistence logic
- Reduce update reload time from 10+ seconds to 3 seconds
- Remove redundant "Switch to X & Update" buttons
- Make channel switching instant with immediate feedback

Users can now simply change the dropdown to switch channels instantly,
then click Apply Update for a fast 3-second reload experience.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-14 11:01:03 +01:00

33 lines
1.1 KiB
JavaScript

PulseApp.theme = (() => {
const htmlElement = document.documentElement;
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)');
let themeToggleButton = null;
function applyTheme(theme) {
if (theme === 'dark') {
htmlElement.classList.add('dark');
localStorage.setItem('theme', 'dark');
} else {
htmlElement.classList.remove('dark');
localStorage.setItem('theme', 'light');
}
}
function init() {
themeToggleButton = document.getElementById('theme-toggle-button');
const savedTheme = localStorage.getItem('theme');
const initialTheme = savedTheme || (prefersDarkScheme.matches ? 'dark' : 'light');
applyTheme(initialTheme);
if (themeToggleButton) {
themeToggleButton.addEventListener('click', function() {
const currentIsDark = htmlElement.classList.contains('dark');
applyTheme(currentIsDark ? 'light' : 'dark');
});
}
}
return {
init
};
})();