Spaces:
Running
Running
Update index.html
Browse files- index.html +12 -2
index.html
CHANGED
|
@@ -472,7 +472,7 @@ input[type=range].lim::-webkit-slider-thumb{background:linear-gradient(135deg,va
|
|
| 472 |
<!-- Auth area: login button (logged-out) / user chip (logged-in) -->
|
| 473 |
<div id="authArea" style="display:flex;align-items:center;gap:8px;margin-left:8px;">
|
| 474 |
<!-- Logged-out -->
|
| 475 |
-
<a id="loginBtn" class="hf-login-btn" href="/oauth/login" target="
|
| 476 |
<svg viewBox="0 0 95 88" fill="none" xmlns="http://www.w3.org/2000/svg">
|
| 477 |
<path d="M47 2 L75 30 Q68 4 47 2Z" fill="currentColor"/>
|
| 478 |
<path d="M19 12 L47 40 L19 12Z" fill="currentColor"/>
|
|
@@ -837,7 +837,6 @@ function showToast(msg,dur=2200){const t=document.getElementById('toast');t.text
|
|
| 837 |
|
| 838 |
// βββ HF OAuth βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 839 |
async function checkAuth() {
|
| 840 |
-
|
| 841 |
try {
|
| 842 |
const res = await fetch('/oauth/user');
|
| 843 |
if (res.ok) {
|
|
@@ -848,6 +847,17 @@ async function checkAuth() {
|
|
| 848 |
showLoggedOut();
|
| 849 |
}
|
| 850 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 851 |
|
| 852 |
|
| 853 |
function showLoggedIn(u) {
|
|
|
|
| 472 |
<!-- Auth area: login button (logged-out) / user chip (logged-in) -->
|
| 473 |
<div id="authArea" style="display:flex;align-items:center;gap:8px;margin-left:8px;">
|
| 474 |
<!-- Logged-out -->
|
| 475 |
+
<a id="loginBtn" class="hf-login-btn" href="/oauth/login" target="_blank">
|
| 476 |
<svg viewBox="0 0 95 88" fill="none" xmlns="http://www.w3.org/2000/svg">
|
| 477 |
<path d="M47 2 L75 30 Q68 4 47 2Z" fill="currentColor"/>
|
| 478 |
<path d="M19 12 L47 40 L19 12Z" fill="currentColor"/>
|
|
|
|
| 837 |
|
| 838 |
// βββ HF OAuth βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 839 |
async function checkAuth() {
|
|
|
|
| 840 |
try {
|
| 841 |
const res = await fetch('/oauth/user');
|
| 842 |
if (res.ok) {
|
|
|
|
| 847 |
showLoggedOut();
|
| 848 |
}
|
| 849 |
|
| 850 |
+
// Re-check auth when user returns to this tab (after popup login)
|
| 851 |
+
document.addEventListener('visibilitychange', () => {
|
| 852 |
+
if (!document.hidden) checkAuth();
|
| 853 |
+
});
|
| 854 |
+
// Also poll every 3s while login popup might be open
|
| 855 |
+
let authPoll = null;
|
| 856 |
+
document.getElementById('loginBtn')?.addEventListener('click', () => {
|
| 857 |
+
authPoll = setInterval(checkAuth, 3000);
|
| 858 |
+
setTimeout(() => clearInterval(authPoll), 120000); // stop after 2min
|
| 859 |
+
});
|
| 860 |
+
|
| 861 |
|
| 862 |
|
| 863 |
function showLoggedIn(u) {
|