mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-01 19:18:35 -04:00
fix(email): open settings after OAuth callback (#5803)
This commit is contained in:
+23
-22
@@ -5790,29 +5790,30 @@ export function close() {
|
|||||||
window.history.replaceState(null, '', clean);
|
window.history.replaceState(null, '', clean);
|
||||||
const success = sp.has('email_oauth_success');
|
const success = sp.has('email_oauth_success');
|
||||||
const errMsg = sp.get('email_oauth_error') || '';
|
const errMsg = sp.get('email_oauth_error') || '';
|
||||||
// Open settings → integrations after the app has initialised.
|
// Open settings → integrations once the document is ready. This module owns
|
||||||
function _tryOpen() {
|
// the open() API, so it does not need to wait for a window-level alias.
|
||||||
if (window.settingsModule && typeof window.settingsModule.open === 'function') {
|
function _showResult() {
|
||||||
window.settingsModule.open('integrations');
|
open('integrations');
|
||||||
// Brief toast-style banner.
|
// Brief toast-style banner.
|
||||||
const banner = document.createElement('div');
|
const banner = document.createElement('div');
|
||||||
banner.textContent = success
|
banner.textContent = success
|
||||||
? '✓ Google account connected — email is ready'
|
? 'Google account connected — email is ready'
|
||||||
: `Google OAuth failed: ${errMsg || 'unknown error'}`;
|
: `Google OAuth failed: ${errMsg || 'unknown error'}`;
|
||||||
Object.assign(banner.style, {
|
Object.assign(banner.style, {
|
||||||
position: 'fixed', bottom: '24px', left: '50%', transform: 'translateX(-50%)',
|
position: 'fixed', bottom: '24px', left: '50%', transform: 'translateX(-50%)',
|
||||||
background: success ? 'var(--accent, #50fa7b)' : 'var(--red, #ff5555)',
|
background: success ? 'var(--accent, #50fa7b)' : 'var(--red, #ff5555)',
|
||||||
color: '#000', padding: '8px 18px', borderRadius: '6px', fontSize: '12px',
|
color: '#000', padding: '8px 18px', borderRadius: '6px', fontSize: '12px',
|
||||||
fontWeight: '600', zIndex: '99999', pointerEvents: 'none',
|
fontWeight: '600', zIndex: '99999', pointerEvents: 'none',
|
||||||
boxShadow: '0 2px 12px rgba(0,0,0,0.3)',
|
boxShadow: '0 2px 12px rgba(0,0,0,0.3)',
|
||||||
});
|
});
|
||||||
document.body.appendChild(banner);
|
document.body.appendChild(banner);
|
||||||
setTimeout(() => banner.remove(), 4000);
|
setTimeout(() => banner.remove(), 4000);
|
||||||
} else {
|
}
|
||||||
setTimeout(_tryOpen, 100);
|
if (document.readyState === 'loading') {
|
||||||
}
|
document.addEventListener('DOMContentLoaded', _showResult, { once: true });
|
||||||
|
} else {
|
||||||
|
_showResult();
|
||||||
}
|
}
|
||||||
_tryOpen();
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const settingsModule = { open, close, initIntegrations, initUnifiedIntegrations, syncAdminVisibility, refreshAiModelEndpoints };
|
const settingsModule = { open, close, initIntegrations, initUnifiedIntegrations, syncAdminVisibility, refreshAiModelEndpoints };
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
"""Regression coverage for the settings UI after Google OAuth redirects."""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
_REPO = Path(__file__).resolve().parents[1]
|
||||||
|
|
||||||
|
|
||||||
|
def test_oauth_redirect_uses_the_module_local_settings_api():
|
||||||
|
source = (_REPO / "static" / "js" / "settings.js").read_text(encoding="utf-8")
|
||||||
|
handler = source[
|
||||||
|
source.index("(function _handleOauthRedirect"):
|
||||||
|
source.index("const settingsModule =")
|
||||||
|
]
|
||||||
|
|
||||||
|
assert "open('integrations');" in handler
|
||||||
|
assert "window.settingsModule" not in handler
|
||||||
|
assert "window.__odysseusAppStarted" not in handler
|
||||||
|
assert "document.addEventListener('DOMContentLoaded', _showResult, { once: true })" in handler
|
||||||
Reference in New Issue
Block a user