forked from firka/student-legacy
fixed kreten status shit maybe idk
This commit is contained in:
parent
9cda8c5d29
commit
b37af9f5a5
@ -62,6 +62,8 @@ Future loginAPI({
|
|||||||
school: school,
|
school: school,
|
||||||
yearId: '1',
|
yearId: '1',
|
||||||
parents: ['Teszt András', 'Teszt Linda'],
|
parents: ['Teszt András', 'Teszt Linda'],
|
||||||
|
json: {"a": "b"},
|
||||||
|
address: '1117 Budapest, Gábor Dénes utca 4.',
|
||||||
),
|
),
|
||||||
role: Role.parent,
|
role: Role.parent,
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
@ -12,6 +14,7 @@ class StatusProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
StatusProvider() {
|
StatusProvider() {
|
||||||
_handleNetworkChanges();
|
_handleNetworkChanges();
|
||||||
|
_handleDNSFailure();
|
||||||
Connectivity().checkConnectivity().then((value) => _networkType = value);
|
Connectivity().checkConnectivity().then((value) => _networkType = value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +27,7 @@ class StatusProvider extends ChangeNotifier {
|
|||||||
_networkType = event;
|
_networkType = event;
|
||||||
if (event == ConnectivityResult.none) {
|
if (event == ConnectivityResult.none) {
|
||||||
if (!_stack.contains(Status.network)) {
|
if (!_stack.contains(Status.network)) {
|
||||||
|
_stack.remove(Status.apiError);
|
||||||
_stack.insert(0, Status.network);
|
_stack.insert(0, Status.network);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
@ -36,6 +40,31 @@ class StatusProvider extends ChangeNotifier {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _handleDNSFailure() {
|
||||||
|
try {
|
||||||
|
InternetAddress.lookup('api.refilc.hu').then((status) {
|
||||||
|
if (status.isEmpty) {
|
||||||
|
if (!_stack.contains(Status.network)) {
|
||||||
|
_stack.remove(Status.apiError);
|
||||||
|
_stack.insert(0, Status.network);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (_stack.contains(Status.network)) {
|
||||||
|
_stack.remove(Status.network);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} on SocketException catch (_) {
|
||||||
|
if (!_stack.contains(Status.network)) {
|
||||||
|
_stack.remove(Status.apiError);
|
||||||
|
_stack.insert(0, Status.network);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void triggerRequest(http.Response res) {
|
void triggerRequest(http.Response res) {
|
||||||
if (res.headers.containsKey("x-maintenance-mode") ||
|
if (res.headers.containsKey("x-maintenance-mode") ||
|
||||||
res.statusCode == 503) {
|
res.statusCode == 503) {
|
||||||
@ -50,6 +79,7 @@ class StatusProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_stack.contains(Status.network)) return;
|
||||||
if (res.body == "invalid_grant" ||
|
if (res.body == "invalid_grant" ||
|
||||||
res.body.replaceAll(' ', '') == '' ||
|
res.body.replaceAll(' ', '') == '' ||
|
||||||
res.statusCode == 400) {
|
res.statusCode == 400) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user