mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-05 02:45:28 +00:00
fix(email): open settings after OAuth callback (#5803)
Some checks failed
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
ci / docker publish / build (amd64) (push) Has been cancelled
ci / docker publish / build (arm64) (push) Has been cancelled
ci / docker publish / merge manifest + tag (push) Has been cancelled
Some checks failed
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
ci / docker publish / build (amd64) (push) Has been cancelled
ci / docker publish / build (arm64) (push) Has been cancelled
ci / docker publish / merge manifest + tag (push) Has been cancelled
This commit is contained in:
parent
28c333e647
commit
25c9e735ef
2 changed files with 42 additions and 22 deletions
|
|
@ -5790,14 +5790,14 @@ 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%)',
|
||||||
|
|
@ -5808,11 +5808,12 @@ export function close() {
|
||||||
});
|
});
|
||||||
document.body.appendChild(banner);
|
document.body.appendChild(banner);
|
||||||
setTimeout(() => banner.remove(), 4000);
|
setTimeout(() => banner.remove(), 4000);
|
||||||
|
}
|
||||||
|
if (document.readyState === 'loading') {
|
||||||
|
document.addEventListener('DOMContentLoaded', _showResult, { once: true });
|
||||||
} else {
|
} else {
|
||||||
setTimeout(_tryOpen, 100);
|
_showResult();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_tryOpen();
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const settingsModule = { open, close, initIntegrations, initUnifiedIntegrations, syncAdminVisibility, refreshAiModelEndpoints };
|
const settingsModule = { open, close, initIntegrations, initUnifiedIntegrations, syncAdminVisibility, refreshAiModelEndpoints };
|
||||||
|
|
|
||||||
19
tests/test_email_oauth_settings_redirect.py
Normal file
19
tests/test_email_oauth_settings_redirect.py
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Reference in a new issue