mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-01-11 22:40:36 +00:00
improve performance of helper method
- compare integers instead of Strings - cache results per day
This commit is contained in:
parent
a63f0d67bd
commit
c8328fa347
1 changed files with 10 additions and 4 deletions
|
|
@ -233,8 +233,12 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
final Map<String, List<Manga>> _dayCache = {};
|
||||
|
||||
List<Manga> _getEntriesForDay(DateTime day, List<Manga> data) {
|
||||
return data.where((e) {
|
||||
final key = "${day.year}-${day.month}-${day.day}";
|
||||
if (_dayCache.containsKey(key)) return _dayCache[key]!;
|
||||
final result = data.where((e) {
|
||||
final lastChapter = e.chapters
|
||||
.filter()
|
||||
.sortByDateUploadDesc()
|
||||
|
|
@ -244,10 +248,12 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
|||
? DateTime.fromMillisecondsSinceEpoch(lastDate)
|
||||
: DateTime.now();
|
||||
final temp = start.add(Duration(days: e.smartUpdateDays!));
|
||||
final predictedDay = "${temp.year}-${temp.month}-${temp.day}";
|
||||
final selectedDay = "${day.year}-${day.month}-${day.day}";
|
||||
return predictedDay == selectedDay;
|
||||
return temp.year == day.year &&
|
||||
temp.month == day.month &&
|
||||
temp.day == day.day;
|
||||
}).toList();
|
||||
_dayCache[key] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Manga> _getEntriesForRange(
|
||||
|
|
|
|||
Loading…
Reference in a new issue