From 4f2abfdaa35d43a8d3ec868a1b27f6f8d0ebf547 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Tue, 13 Jan 2026 19:48:27 +0800 Subject: feat: enhance Microsoft login flow with status updates and polling management --- ui/src/App.svelte | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'ui/src/App.svelte') diff --git a/ui/src/App.svelte b/ui/src/App.svelte index 914a5ea..beb3403 100644 --- a/ui/src/App.svelte +++ b/ui/src/App.svelte @@ -64,6 +64,8 @@ let offlineUsername = ""; let deviceCodeData: DeviceCodeResponse | null = null; let msLoginLoading = false; + let msLoginStatus = "Waiting for authorization..."; + let isPollingRequestActive = false; onMount(async () => { checkAccount(); @@ -126,6 +128,7 @@ } function closeLoginModal() { + stopPolling(); isLoginModalOpen = false; } @@ -154,6 +157,7 @@ async function startMicrosoftLogin() { loginMode = "microsoft"; msLoginLoading = true; + msLoginStatus = "Waiting for authorization..."; stopPolling(); // Ensure no duplicates try { @@ -188,6 +192,9 @@ } async function checkLoginStatus(deviceCode: string) { + if (isPollingRequestActive) return; + isPollingRequestActive = true; + console.log("Polling Microsoft API..."); try { // This will fail with "authorization_pending" until user logs in @@ -204,9 +211,12 @@ const errStr = e.toString(); if (errStr.includes("authorization_pending")) { console.log("Status: Waiting for user to authorize..."); + // Keep checking } else { // Real error console.error("Polling Error:", errStr); + msLoginStatus = "Error: " + errStr; + // Optional: Stop polling on fatal errors? // expired_token should stop it. if ( @@ -218,6 +228,8 @@ loginMode = "select"; } } + } finally { + isPollingRequestActive = false; } } @@ -226,11 +238,6 @@ if (deviceCodeData) checkLoginStatus(deviceCodeData.device_code); } - function closeLoginModal() { - stopPolling(); - isLoginModalOpen = false; - } - function openLink(url: string) { open(url); } @@ -669,7 +676,7 @@
- Waiting for authorization... + {msLoginStatus}

This window will update automatically.

-- cgit v1.2.3-70-g09d2