improved performance and battery usage on older devices
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import '../../../../../api/marianumconnect/queries/timetable_get_week/timetable_get_week_response.dart';
|
||||
import '../../../../../extensions/date_time.dart';
|
||||
import '../../../../../utils/json_equality.dart';
|
||||
|
||||
/// Weeks kept around the viewed week and around today's week. Everything
|
||||
/// further away is dropped: every state emit re-serializes the whole cache for
|
||||
/// HydratedBloc and the calendar rebuilds its appointments from all of it, so
|
||||
/// an unbounded cache makes week swipes slower the longer the app is used.
|
||||
const int kWeekCacheRadius = 4;
|
||||
const int kWeekCacheRadius = 8;
|
||||
|
||||
/// Returns the cache with [week] stored under [weekStart], pruned to the
|
||||
/// weeks near [viewedWeekStart] or [now]. Returns null when the stored week
|
||||
@@ -21,10 +20,7 @@ Map<String, TimetableGetWeekResponse>? mergeWeekIntoCache(
|
||||
}) {
|
||||
final key = weekStart.weekKey();
|
||||
final existing = cache[key];
|
||||
if (existing != null &&
|
||||
const DeepCollectionEquality().equals(existing.toJson(), week.toJson())) {
|
||||
return null;
|
||||
}
|
||||
if (sameJson(existing, week)) return null;
|
||||
|
||||
final viewedMonday = viewedWeekStart.mondayOfWeek;
|
||||
final todayMonday = now.mondayOfWeek;
|
||||
|
||||
Reference in New Issue
Block a user