Skip to content

Commit

Permalink
v0.1.3
Browse files Browse the repository at this point in the history
- Prüfung eingebaut ob ein URL konfiguriert ist
  • Loading branch information
sterlp committed Jul 18, 2021
1 parent 85d37fa commit f03db85
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.1.3

- Prüfung eingebaut ob ein URL konfiguriert ist

# 0.1.2

- HTTP Timeout von zwei Sekunden hinzugefügt
Expand Down
41 changes: 23 additions & 18 deletions solvis_v2_app/lib/homescreen/solvis_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,28 +161,33 @@ class _SolvisWidgetState extends State<SolvisWidget> with WidgetsBindingObserver
}

Future<void> refresh() async {
debugPrint('refresh screen image, error count: ${_errorCounter.eventCount} ...');
try {
final r = await widget._container.get<SolvisClient>().loadScreen();
if (r.statusCode < 299) {
_errorCounter.reset();
autoRefresh();
return decodeImageFromList(r.bodyBytes).then((i) =>
setState(() => _image = ImageEditor(i)));
} else {
if (r.statusCode == 401) {
const problem = 'HTTP 401: Falscher Benutzername oder Password!';
setState(() => _errorCounter.maxReached(problem));
final client = widget._container.get<SolvisClient>();
if (client.hasUrl) {
debugPrint('refresh screen image, error count: ${_errorCounter.eventCount} ...');
try {
final r = await widget._container.get<SolvisClient>().loadScreen();
if (r.statusCode < 299) {
_errorCounter.reset();
autoRefresh();
return decodeImageFromList(r.bodyBytes).then((i) =>
setState(() => _image = ImageEditor(i)));
} else {
throw '${r.statusCode}: ${r.body}';
if (r.statusCode == 401) {
_errorCounter.maxReached('HTTP 401: Falscher Benutzername oder Password!');
} else {
throw '${r.statusCode}: ${r.body}';
}
return;
}
} catch (e) {
if (_errorCounter.count(e).isMaxNotReached) {
autoRefresh();
}
return;
}
} catch (e) {
if (_errorCounter.count(e).isMaxNotReached) {
autoRefresh();
}
} else {
_errorCounter.maxReached('Kein URL für den Zugriff auf die Heizung konfiguriert!');
}

setState(() {});
}
}
2 changes: 1 addition & 1 deletion solvis_v2_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.1.2+3
version: 0.1.3+4

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit f03db85

Please sign in to comment.