Skip to content

Commit 430d4ae

Browse files
committed
fix stability
1 parent 0c5bdfe commit 430d4ae

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/view/main.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class _MainActivityState extends State<MainActivity>
9292
setState(() {
9393
_performChangeUser(sp.getString(DatabaseKeys.USER) ??
9494
CodeWarsAPI.getErrorWithReason("not set"));
95+
_performChangeCompleted(sp.getString(DatabaseKeys.COMPLETED) ??
96+
CodeWarsAPI.getErrorWithReason("not set"));
9597
});
9698
});
9799
}
@@ -126,7 +128,7 @@ class _MainActivityState extends State<MainActivity>
126128
..timeout(new Duration(seconds: 10))
127129
..catchError(() {
128130
SharedPreferences.getInstance().then((sp) {
129-
sp.setString(DatabaseKeys.USER, CodeWarsAPI
131+
sp.setString(DatabaseKeys.COMPLETED, CodeWarsAPI
130132
.getErrorWithReason("time out"));
131133
});
132134
setState(() {
@@ -147,7 +149,7 @@ class _MainActivityState extends State<MainActivity>
147149
barrierDismissible: false);
148150
get(CodeWarsAPI.getUser(_user.username))
149151
..then((val) {
150-
setState(() => _performChangeCompleted(val.body));
152+
setState(() => _performChangeUser(val.body));
151153
SharedPreferences.getInstance().then((sp) {
152154
sp.setString(DatabaseKeys.USER, val.body);
153155
});
@@ -197,9 +199,8 @@ class _MainActivityState extends State<MainActivity>
197199
if (null != reason) {
198200
_me.displayWhenEmpty = reason;
199201
_user = null;
200-
} else {
202+
} else
201203
_user = new CodeWarsUser.fromJson(json);
202-
}
203204
}
204205

205206
_performChangeCompleted(String _json) {
@@ -208,10 +209,8 @@ class _MainActivityState extends State<MainActivity>
208209
if (null != reason) {
209210
_kata.displayWhenEmpty = reason;
210211
_completed = null;
211-
} else {
212+
} else
212213
_completed = KataCompleted.fromJson(json);
213-
print(_completed.toString());
214-
}
215214
}
216215

217216
@override

0 commit comments

Comments
 (0)