Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #586 (Load the latest animations) #594

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/pages/popular/popular_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ abstract class _PopularController with Store {
searchKeyword = s;
}

Future<bool> queryLatestBangumiUpdates() async {
var result = await BangumiHTTP.getCalendar();
List<BangumiItem> bangumiList = [];
var today = DateTime.now().weekday;
List<List<int>> weekdayOrder = [
[1, 7, 6],
[2, 1, 7],
[3, 2, 1],
[4, 3, 2],
[5, 4, 3],
[6, 5, 4],
[7, 6, 5],
];
for (int day in weekdayOrder[today - 1]) {
bangumiList.addAll(result[day - 1]);
}
// [X|未实现]只保留tags中含有 "tag": ["日本"] 的番剧,效率很低
this.bangumiList = ObservableList.of(bangumiList);
return true;
}

Future<bool> queryBangumiListFeed() async {
isLoadingMore = true;
int randomNumber = Random().nextInt(1000) + 1;
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/popular/popular_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class _PopularPageState extends State<PopularPage>
}
});
if (popularController.bangumiList.isEmpty) {
popularController.queryBangumiListFeed();
popularController.queryLatestBangumiUpdates();
}
popularController.isSearching = popularController.searchKeyword.isNotEmpty;
showSearchBar = popularController.searchKeyword.isNotEmpty;
Expand Down
Loading