Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -2336,8 +2336,15 @@ SELECTION_JS = """
2336
  document.body.classList.toggle('dark', dark);
2337
  const container = document.querySelector('.gradio-container');
2338
  if (container) container.classList.toggle('dark', dark);
2339
- const el = document.getElementById('theme-emoji');
2340
- if (el) el.textContent = dark ? '☀️' : '🌙';
 
 
 
 
 
 
 
2341
  }
2342
  function toggleDark() {
2343
  const url = new URL(window.location);
 
2336
  document.body.classList.toggle('dark', dark);
2337
  const container = document.querySelector('.gradio-container');
2338
  if (container) container.classList.toggle('dark', dark);
2339
+ // Sync emoji and checkbox — retry until element is available
2340
+ function syncUI() {
2341
+ const el = document.getElementById('theme-emoji');
2342
+ const cb = document.getElementById('dark-toggle-btn');
2343
+ if (el) el.textContent = dark ? '☀️' : '🌙';
2344
+ if (cb) cb.checked = dark;
2345
+ if (!el || !cb) requestAnimationFrame(syncUI);
2346
+ }
2347
+ syncUI();
2348
  }
2349
  function toggleDark() {
2350
  const url = new URL(window.location);