improved performance and battery usage on older devices
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:enough_icalendar/enough_icalendar.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../bloc/marianum_dates_state.dart';
|
||||
|
||||
@@ -19,6 +20,12 @@ class MarianumDatesGetEvents {
|
||||
final body = response.data;
|
||||
if (body == null || body.isEmpty) return [];
|
||||
|
||||
// The public feed holds hundreds of events back to 1981; parsing it on
|
||||
// the UI isolate froze the page for a noticeable moment on every open.
|
||||
return compute(parseEvents, body);
|
||||
}
|
||||
|
||||
static List<MarianumDate> parseEvents(String body) {
|
||||
final root = VComponent.parse(body);
|
||||
final calendar = root is VCalendar ? root : null;
|
||||
final source = calendar?.children ?? root.children;
|
||||
|
||||
Reference in New Issue
Block a user