Skip to content

Commit

Permalink
fix timeline page mobx (Predidit#482)
Browse files Browse the repository at this point in the history
(cherry picked from commit 55ee343)
  • Loading branch information
Predidit authored and ErBWs committed Dec 19, 2024
1 parent 662fafe commit d98992f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
12 changes: 7 additions & 5 deletions lib/pages/timeline/timeline_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,34 @@ class TimelineController = _TimelineController with _$TimelineController;

abstract class _TimelineController with Store {
@observable
List<List<BangumiItem>> bangumiCalendar = [];
ObservableList<List<BangumiItem>> bangumiCalendar = ObservableList<List<BangumiItem>>();

@observable
String seasonString = '';

DateTime selectedDate = DateTime.now();

Future<void> getSchedules() async {
bangumiCalendar = await BangumiHTTP.getCalendar();
final resBangumiCalendar = await BangumiHTTP.getCalendar();
bangumiCalendar.clear();
bangumiCalendar.addAll(resBangumiCalendar);
}

Future<void> getSchedulesBySeason() async {
// 4次获取,每次最多20部
var time = 0;
const maxTime = 4;
const limit = 20;
bangumiCalendar = List.generate(7, (_) => <BangumiItem>[]);
var resBangumiCalendar = List.generate(7, (_) => <BangumiItem>[]);
for (time = 0; time < maxTime; time++) {
final offset = time * limit;
var newList = await BangumiHTTP.getCalendarBySearch(
AnimeSeason(selectedDate).toSeasonStartAndEnd(), limit, offset);
for (int i = 0; i < bangumiCalendar.length; ++i) {
bangumiCalendar[i].addAll(newList[i]);
}
// MobX
bangumiCalendar = List.from(bangumiCalendar);
bangumiCalendar.clear();
bangumiCalendar.addAll(resBangumiCalendar);
}
}
}
4 changes: 2 additions & 2 deletions lib/pages/timeline/timeline_controller.g.dart

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

4 changes: 2 additions & 2 deletions lib/request/bangumi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class BangumiHTTP {
};
}
try {
final res = await Request().post(Api.bangumiRankSearch,
final res = await Request().post(Api.formatUrl(Api.bangumiRankSearch, [100, 0]),
data: params,
options: Options(
headers: bangumiHTTPHeader, contentType: 'application/json'));
Expand Down Expand Up @@ -151,7 +151,7 @@ class BangumiHTTP {
};

try {
final res = await Request().post(Api.bangumiRankSearch,
final res = await Request().post(Api.formatUrl(Api.bangumiRankSearch, [100, 0]),
data: params,
options: Options(
headers: bangumiHTTPHeader, contentType: 'application/json'));
Expand Down

0 comments on commit d98992f

Please sign in to comment.