Skip to content

Commit d724568

Browse files
committed
prevent dup redirect
1 parent 5862b6b commit d724568

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

.github/workflows/deploy_static.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
name: Deploy static content to Pages
22

33
on:
4+
# Runs on pushes targeting the default branch
45
push:
5-
tags:
6-
- "*"
6+
# branches: ["main"]
7+
branches: ["**"]
8+
# on:
9+
# push:
10+
# tags:
11+
# - "*"
712

813
# Allows you to run this workflow manually from the Actions tab
914
workflow_dispatch:

oauth-callback.html

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ <h1>✅ Authentication Successful!</h1>
107107
<script>
108108
(function() {
109109
try {
110+
// Prevent duplicate execution on mobile (when switching back to browser)
111+
const redirectKey = 'atmosphere_oauth_redirected';
112+
if (sessionStorage.getItem(redirectKey) === 'true') {
113+
// Already redirected, show completion message
114+
document.querySelector('.spinner').style.display = 'none';
115+
document.querySelector('h1').textContent = '✅ Redirected!';
116+
document.getElementById('status').textContent = 'Return to Obsidian to complete login.';
117+
document.getElementById('manual-link').classList.add('show');
118+
return;
119+
}
120+
110121
// extract OAuth parameters from URL hash (not search string)
111122
const params = new URLSearchParams(window.location.hash.slice(1));
112123

@@ -115,7 +126,14 @@ <h1>✅ Authentication Successful!</h1>
115126
// store the URI for manual copy
116127
document.getElementById('link-text').textContent = obsidianUri;
117128

118-
window.location.href = obsidianUri;
129+
// Mark as redirected BEFORE the redirect to prevent race conditions
130+
sessionStorage.setItem(redirectKey, 'true');
131+
132+
// Small delay to ensure any pending IndexedDB writes complete
133+
// This is important on mobile where the browser may suspend the tab
134+
setTimeout(function() {
135+
window.location.href = obsidianUri;
136+
}, 100);
119137

120138
setTimeout(function() {
121139
const spinner = document.querySelector('.spinner');

0 commit comments

Comments
 (0)