Fix login page error message shown on initial load
Add auto-retry logic in KretenLoginWidget so that the first web resource error silently retries once before showing the error UI. This prevents the error message from appearing immediately when the e-KRÉTA server is briefly unreachable (e.g., transient network issues), resolving the App Store Guideline 2.1(a) rejection. https://claude.ai/code/session_016dhktF2DaoTQeifUaZrxbP
This commit is contained in:
@@ -45,6 +45,8 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
|
||||
String _errorMessage = '';
|
||||
bool _hasTimedOut = false;
|
||||
Timer? _timeoutTimer;
|
||||
int _autoRetryCount = 0;
|
||||
static const int _maxAutoRetries = 1;
|
||||
|
||||
static const _loginUrl =
|
||||
'https://idp.e-kreta.hu/connect/authorize?prompt=login&nonce=wylCrqT4oN6PPgQn2yQB0euKei9nJeZ6_ffJ-VpSKZU&response_type=code&code_challenge_method=S256&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&code_challenge=HByZRRnPGb-Ko_wTI7ibIba1HQ6lor0ws4bcgReuYSQ&redirect_uri=https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect&client_id=kreta-ellenorzo-student-mobile-ios&state=refilc_student_mobile';
|
||||
@@ -110,6 +112,7 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
|
||||
}
|
||||
});
|
||||
|
||||
_autoRetryCount = 0;
|
||||
_startTimeoutTimer();
|
||||
},
|
||||
onProgress: (progress) {
|
||||
@@ -141,6 +144,14 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
// Auto-retry once on first error before showing the error UI,
|
||||
// to handle transient network issues on initial load.
|
||||
if (_autoRetryCount < _maxAutoRetries) {
|
||||
_autoRetryCount++;
|
||||
_retryLoad();
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_hasError = true;
|
||||
_errorMessage = error.description;
|
||||
@@ -165,6 +176,18 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
|
||||
});
|
||||
}
|
||||
|
||||
void _retryLoad() {
|
||||
setState(() {
|
||||
_hasError = false;
|
||||
_errorMessage = '';
|
||||
_hasTimedOut = false;
|
||||
_initialPageLoaded = false;
|
||||
loadingPercentage = 0;
|
||||
});
|
||||
controller.loadRequest(Uri.parse(_loginUrl));
|
||||
_startTimeoutTimer();
|
||||
}
|
||||
|
||||
void _retry() {
|
||||
setState(() {
|
||||
_hasError = false;
|
||||
@@ -174,6 +197,7 @@ class _KretenLoginWidgetState extends State<KretenLoginWidget>
|
||||
loadingPercentage = 0;
|
||||
_hasFadedIn = false;
|
||||
});
|
||||
_autoRetryCount = 0;
|
||||
_animationController.reset();
|
||||
controller.loadRequest(Uri.parse(_loginUrl));
|
||||
_startTimeoutTimer();
|
||||
|
||||
Reference in New Issue
Block a user