Skip to content

Commit

Permalink
Instant timetable load with quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed Feb 8, 2024
1 parent 0633ea7 commit 8c5f423
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ class TimeTable {
}

Future<TimeTableData> loadTt(DateTime date) async {
if (timetables.containsKey(date)) {
return timetables[date]!;
DateTime dateOnly = DateTime(date.year, date.month, date.day);
if (timetables.containsKey(dateOnly)) {
return timetables[dateOnly]!;
}

Response response = await data.dio.get(
Expand Down Expand Up @@ -257,7 +258,6 @@ class TimeTable {
ttClasses,
periods!));

DateTime dateOnly = DateTime(date.year, date.month, date.day);
timetables[dateOnly] = t;
await saveToCache();
return t;
Expand All @@ -282,9 +282,11 @@ class TimeTable {
}
}
periods = await loadPeriods(data.user.token);
recentTimetables.add(processTimeTable(
TimeTableData(DateTime.parse(day.key), ttClasses, periods!)));
timetables[DateTime.parse(day.key)] = recentTimetables.last;
DateTime date = DateTime.parse(day.key);
recentTimetables
.add(processTimeTable(TimeTableData(date, ttClasses, periods!)));
DateTime dateOnly = DateTime(date.year, date.month, date.day);
timetables[dateOnly] = recentTimetables.last;
}

await saveToCache();
Expand Down
2 changes: 1 addition & 1 deletion lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ class HomePageState extends State<HomePage> {
@override
void initState() {
super.initState();
getData();
fetchAndCompareBuildName();
getData(); //fetching data
}

@override
Expand Down

0 comments on commit 8c5f423

Please sign in to comment.