forked from firka/student-legacy
Ignore disabled live activity
This commit is contained in:
parent
85c6d548ad
commit
cc40fb9c0f
@ -44,10 +44,20 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
required SettingsProvider settings,
|
required SettingsProvider settings,
|
||||||
}) : _timetable = timetable,
|
}) : _timetable = timetable,
|
||||||
_settings = settings {
|
_settings = settings {
|
||||||
_liveActivitiesPlugin.init(appGroupId: "group.refilc.livecard");
|
// Check if live card is enabled .areActivitiesEnabled()
|
||||||
|
_liveActivitiesPlugin.areActivitiesEnabled().then((value) {
|
||||||
|
// Console log
|
||||||
|
print("Live card enabled: $value");
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
_liveActivitiesPlugin.init(appGroupId: "group.refilc2.livecard");
|
||||||
|
|
||||||
_liveActivitiesPlugin.getAllActivitiesIds().then((value) {
|
_liveActivitiesPlugin.getAllActivitiesIds().then((value) {
|
||||||
_latestActivityId = value.isNotEmpty ? value.first : null;
|
_latestActivityId = value.isNotEmpty ? value.first : null;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
_timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
|
_timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
|
||||||
_delay = settings.bellDelayEnabled
|
_delay = settings.bellDelayEnabled
|
||||||
? Duration(seconds: settings.bellDelay)
|
? Duration(seconds: settings.bellDelay)
|
||||||
@ -58,8 +68,15 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_timer.cancel();
|
_timer.cancel();
|
||||||
if (_latestActivityId != null && Platform.isIOS)
|
if (Platform.isIOS) {
|
||||||
|
_liveActivitiesPlugin.areActivitiesEnabled().then((value) {
|
||||||
|
if (value) {
|
||||||
|
if (_latestActivityId != null) {
|
||||||
_liveActivitiesPlugin.endActivity(_latestActivityId!);
|
_liveActivitiesPlugin.endActivity(_latestActivityId!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +163,8 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
void update() async {
|
void update() async {
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
|
_liveActivitiesPlugin.areActivitiesEnabled().then((value) {
|
||||||
|
if (value) {
|
||||||
final cmap = toMap();
|
final cmap = toMap();
|
||||||
if (!mapEquals(cmap, _lastActivity)) {
|
if (!mapEquals(cmap, _lastActivity)) {
|
||||||
_lastActivity = cmap;
|
_lastActivity = cmap;
|
||||||
@ -171,6 +190,8 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
List<Lesson> today = _today(_timetable);
|
List<Lesson> today = _today(_timetable);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user