Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -2336,15 +2336,22 @@ 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
- // 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);
 
2336
  document.body.classList.toggle('dark', dark);
2337
  const container = document.querySelector('.gradio-container');
2338
  if (container) container.classList.toggle('dark', dark);
2339
+
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) return true;
2346
+ return false;
2347
+ }
2348
+
2349
+ if (!syncUI()) {
2350
+ const observer = new MutationObserver(() => {
2351
+ if (syncUI()) observer.disconnect();
2352
+ });
2353
+ observer.observe(document.body, { childList: true, subtree: true });
2354
  }
 
2355
  }
2356
  function toggleDark() {
2357
  const url = new URL(window.location);