migrated custom timetable events to Marianum-Connect and refactored push notification handling
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:developer';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../../../api/marianumconnect/queries/timetable_custom_events/custom_events_migration.dart';
|
||||
import '../../../../../api/marianumconnect/queries/timetable_get_week/timetable_get_week_response.dart';
|
||||
import '../../../../../api/mhsl/custom_timetable_event/custom_timetable_event.dart';
|
||||
import '../../../../../extensions/date_time.dart';
|
||||
@@ -187,6 +188,7 @@ class TimetableBloc
|
||||
bool renew = false,
|
||||
}) async {
|
||||
try {
|
||||
await CustomEventsMigration.runOnce();
|
||||
final events = await repo.data.getCustomEvents(
|
||||
renew: renew,
|
||||
onError: onError,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import '../../../../../api/demo/data/demo_timetable.dart';
|
||||
import '../../../../../api/demo/demo_mode.dart';
|
||||
import '../../../../../api/marianumconnect/queries/timetable_custom_events/timetable_custom_events_add.dart';
|
||||
import '../../../../../api/marianumconnect/queries/timetable_custom_events/timetable_custom_events_cache.dart';
|
||||
import '../../../../../api/marianumconnect/queries/timetable_custom_events/timetable_custom_events_remove.dart';
|
||||
import '../../../../../api/marianumconnect/queries/timetable_custom_events/timetable_custom_events_update.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';
|
||||
@@ -12,22 +16,13 @@ import '../../../../../api/marianumconnect/queries/timetable_get_timegrid/timeta
|
||||
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/marianumconnect/queries/timetable_get_week/timetable_get_week_response.dart';
|
||||
import '../../../../../api/mhsl/custom_timetable_event/add/add_custom_timetable_event.dart';
|
||||
import '../../../../../api/mhsl/custom_timetable_event/add/add_custom_timetable_event_params.dart';
|
||||
import '../../../../../api/mhsl/custom_timetable_event/custom_timetable_event.dart';
|
||||
import '../../../../../api/mhsl/custom_timetable_event/get/get_custom_timetable_event_cache.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 '../../../../../api/mhsl/custom_timetable_event/remove/remove_custom_timetable_event.dart';
|
||||
import '../../../../../api/mhsl/custom_timetable_event/remove/remove_custom_timetable_event_params.dart';
|
||||
import '../../../../../api/mhsl/custom_timetable_event/update/update_custom_timetable_event.dart';
|
||||
import '../../../../../api/mhsl/custom_timetable_event/update/update_custom_timetable_event_params.dart';
|
||||
import '../../../../../api/request_cache.dart';
|
||||
import '../../../../../model/account_data.dart';
|
||||
|
||||
/// Pulls the timetable from the Marianum-Connect mobile API. Each endpoint is
|
||||
/// its own HTTP call; this provider exposes the lazy futures so the bloc can
|
||||
/// chain them without seeing the dio layer. Custom events still come from MHSL.
|
||||
/// chain them without seeing the dio layer.
|
||||
class TimetableDataProvider {
|
||||
Future<TimetableGetWeekResponse> getWeek(
|
||||
DateTime startDate,
|
||||
@@ -100,12 +95,11 @@ class TimetableDataProvider {
|
||||
}) {
|
||||
if (DemoMode.active) return Future.value(DemoTimetable.customEvents());
|
||||
return resolveFromCache<GetCustomTimetableEventResponse>(
|
||||
(onUpdate, onError) => GetCustomTimetableEventCache(
|
||||
GetCustomTimetableEventParams(AccountData().getUserSecret()),
|
||||
renew: renew,
|
||||
onUpdate: onUpdate,
|
||||
onError: onError,
|
||||
),
|
||||
(onUpdate, onError) => TimetableCustomEventsCache(
|
||||
renew: renew,
|
||||
onUpdate: onUpdate,
|
||||
onError: onError,
|
||||
),
|
||||
onError: onError,
|
||||
operationName: 'getCustomEvents',
|
||||
);
|
||||
@@ -113,20 +107,16 @@ class TimetableDataProvider {
|
||||
|
||||
Future<void> addCustomEvent(CustomTimetableEvent event) {
|
||||
if (DemoMode.active) return Future.value();
|
||||
return AddCustomTimetableEvent(
|
||||
AddCustomTimetableEventParams(AccountData().getUserSecret(), event),
|
||||
).run();
|
||||
return TimetableCustomEventsAdd().run(event);
|
||||
}
|
||||
|
||||
Future<void> updateCustomEvent(String id, CustomTimetableEvent event) {
|
||||
if (DemoMode.active) return Future.value();
|
||||
return UpdateCustomTimetableEvent(
|
||||
UpdateCustomTimetableEventParams(id, event),
|
||||
).run();
|
||||
return TimetableCustomEventsUpdate().run(id, event);
|
||||
}
|
||||
|
||||
Future<void> removeCustomEvent(String id) {
|
||||
if (DemoMode.active) return Future.value();
|
||||
return RemoveCustomTimetableEvent(RemoveCustomTimetableEventParams(id)).run();
|
||||
return TimetableCustomEventsRemove().run(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user