Skip to content

Commit

Permalink
Handle api error
Browse files Browse the repository at this point in the history
  • Loading branch information
神楽坂花火 committed Apr 16, 2021
1 parent 889b0ac commit 3aedde1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .idea/dictionaries/KagurazakaHanabi.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 13 additions & 15 deletions lib/pages/recent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:scoped_model/scoped_model.dart';

class RecentPage extends StatefulWidget {

@override
_RecentPageState createState() => _RecentPageState();

Expand Down Expand Up @@ -154,20 +153,19 @@ class _RecentPageState extends State<RecentPage>

Future<void> _fetchData() async {
doing = true;
Recents recents = await TujianApi.getRecents(
sort: current,
page: cur[current],
size: 20,
);
List<Picture> data = recents.data;
List<String> list = Settings.marked;
for (int i = 0; i < data.length; i++) {
data[i].marked = list.contains(data[i].id);
}
max[current] = recents.maximum;
doing = false;
AppModel.of(context).recent.addAll(data);
setState(() {});
TujianApi.getRecents(sort: current, page: cur[current], size: 20).then((recents) {
List<Picture> data = recents.data;
List<String> list = Settings.marked;
for (int i = 0; i < data.length; i++) {
data[i].marked = list.contains(data[i].id);
}
max[current] = recents.maximum;
doing = false;
AppModel.of(context).recent.addAll(data);
if (mounted) setState(() {});
}).catchError((_) {
doing = false;
});
}

List<Picture> _where(String tid) {
Expand Down

0 comments on commit 3aedde1

Please sign in to comment.