fixed widget background refresh loading custom events from the legacy backend
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:workmanager/workmanager.dart';
|
||||
|
||||
import '../api/marianumconnect/marianumconnect_endpoint.dart';
|
||||
import '../api/marianumconnect/queries/timetable_custom_events/timetable_custom_events_get.dart';
|
||||
import '../api/marianumconnect/queries/timetable_get_holidays/timetable_get_holidays.dart';
|
||||
import '../api/marianumconnect/queries/timetable_get_holidays/timetable_get_holidays_response.dart';
|
||||
import '../api/marianumconnect/queries/timetable_get_rooms/timetable_get_rooms.dart';
|
||||
@@ -15,8 +16,6 @@ import '../api/marianumconnect/queries/timetable_get_subjects/timetable_get_subj
|
||||
import '../api/marianumconnect/queries/timetable_get_timegrid/timetable_get_timegrid.dart';
|
||||
import '../api/marianumconnect/queries/timetable_get_timegrid/timetable_get_timegrid_response.dart';
|
||||
import '../api/marianumconnect/queries/timetable_get_week/timetable_get_week.dart';
|
||||
import '../api/mhsl/custom_timetable_event/get/get_custom_timetable_event.dart';
|
||||
import '../api/mhsl/custom_timetable_event/get/get_custom_timetable_event_params.dart';
|
||||
import '../api/mhsl/custom_timetable_event/get/get_custom_timetable_event_response.dart';
|
||||
import '../session/session.dart';
|
||||
import '../session/session_manager.dart';
|
||||
@@ -106,7 +105,7 @@ class WidgetBackgroundTask {
|
||||
log('[widget-refresh] snapshot is fresh, skipping refresh');
|
||||
return;
|
||||
}
|
||||
await _refresh(session);
|
||||
await _refresh();
|
||||
}
|
||||
|
||||
static Future<void> cancelAll() async {
|
||||
@@ -143,7 +142,7 @@ void _callbackDispatcher() {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _refresh(Session session) async {
|
||||
Future<void> _refresh() async {
|
||||
await WidgetSync.ensureInitialized();
|
||||
// The background isolate doesn't go through main.dart's BlocBuilder, so we
|
||||
// re-apply the endpoint the foreground last persisted. Without this the
|
||||
@@ -182,14 +181,9 @@ Future<void> _refresh(Session session) async {
|
||||
final timegridFuture = _runOrNull<TimetableGetTimegridResponse>(
|
||||
() => TimetableGetTimegrid().run(),
|
||||
);
|
||||
final customEventsFuture = switch (session) {
|
||||
CredentialSession(:final legacyUserSecret) =>
|
||||
_runOrNull<GetCustomTimetableEventResponse>(
|
||||
() => GetCustomTimetableEvent(
|
||||
GetCustomTimetableEventParams(legacyUserSecret),
|
||||
).run(),
|
||||
),
|
||||
};
|
||||
final customEventsFuture = _runOrNull<GetCustomTimetableEventResponse>(
|
||||
() => TimetableCustomEventsGet().run(),
|
||||
);
|
||||
final timetable = await timetableFuture;
|
||||
final subjects = await subjectsFuture;
|
||||
final rooms = await roomsFuture;
|
||||
|
||||
Reference in New Issue
Block a user