WeMWish commited on
Commit
39a107a
·
1 Parent(s): 38c519c

Fix OAuth loading indicator to persist during callback processing

Browse files

- Show loading indicator immediately when page loads with OAuth code
- Maintain loading state throughout OAuth callback processing
- Prevents confusing UX where button reappears without feedback
- Loading indicator now visible from click through authentication completion

Files changed (2) hide show
  1. CHANGELOG.md +3 -1
  2. ui.R +13 -0
CHANGELOG.md CHANGED
@@ -52,7 +52,9 @@
52
  ### Added
53
  - **OAuth Loading Indicator**
54
  - Added loading spinner under sign in button during OAuth redirect
55
- - Shows "Redirecting to Hugging Face..." message
 
 
56
  - Button disables during redirect to prevent double-clicks
57
  - Uses Bootstrap spinner for consistent styling
58
 
 
52
  ### Added
53
  - **OAuth Loading Indicator**
54
  - Added loading spinner under sign in button during OAuth redirect
55
+ - Shows "Redirecting to Hugging Face..." message during entire OAuth flow
56
+ - Loading indicator persists during OAuth callback processing
57
+ - Shows immediately when returning from HuggingFace with auth code
58
  - Button disables during redirect to prevent double-clicks
59
  - Uses Bootstrap spinner for consistent styling
60
 
ui.R CHANGED
@@ -1552,6 +1552,16 @@ ui <- navbarPage(
1552
  tags$script(
1553
  HTML(
1554
  "
 
 
 
 
 
 
 
 
 
 
1555
  // Check authentication state and show/hide overlay
1556
  Shiny.addCustomMessageHandler('auth_state', function(message) {
1557
  var overlay = document.getElementById('authOverlay');
@@ -1567,6 +1577,9 @@ ui <- navbarPage(
1567
  var urlParams = new URLSearchParams(window.location.search);
1568
  if (urlParams.has('code')) {
1569
  console.log('OAuth code found in URL, sending to Shiny');
 
 
 
1570
  var code = urlParams.get('code');
1571
  Shiny.setInputValue('oauth_code', code, {priority: 'event'});
1572
  // Clean URL
 
1552
  tags$script(
1553
  HTML(
1554
  "
1555
+ // Check for OAuth code on page load (before Shiny connects)
1556
+ $(document).ready(function() {
1557
+ var urlParams = new URLSearchParams(window.location.search);
1558
+ if (urlParams.has('code')) {
1559
+ // Show loading indicator immediately
1560
+ $('#authLoadingIndicator').show();
1561
+ $('#hfSignInBtn').prop('disabled', true);
1562
+ }
1563
+ });
1564
+
1565
  // Check authentication state and show/hide overlay
1566
  Shiny.addCustomMessageHandler('auth_state', function(message) {
1567
  var overlay = document.getElementById('authOverlay');
 
1577
  var urlParams = new URLSearchParams(window.location.search);
1578
  if (urlParams.has('code')) {
1579
  console.log('OAuth code found in URL, sending to Shiny');
1580
+ // Show loading indicator during OAuth processing
1581
+ $('#authLoadingIndicator').show();
1582
+ $('#hfSignInBtn').prop('disabled', true);
1583
  var code = urlParams.get('code');
1584
  Shiny.setInputValue('oauth_code', code, {priority: 'event'});
1585
  // Clean URL