improved performance and battery usage on older devices
This commit is contained in:
+8
-16
@@ -1,6 +1,6 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:localstore/localstore.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../../model/account_data.dart';
|
||||
import '../../../demo/demo_mode.dart';
|
||||
@@ -21,9 +21,7 @@ import 'timetable_custom_events_add.dart';
|
||||
/// failure only sees the events that were not yet moved, so nothing is
|
||||
/// duplicated. The flag is set only once MHSL reports no remaining events.
|
||||
class CustomEventsMigration {
|
||||
static const String _collection = 'MarianumMobile';
|
||||
static const String _document = 'customEventsMigration';
|
||||
static const String _doneKey = 'migratedToMc';
|
||||
static const String _doneKey = 'customEventsMigratedToMc';
|
||||
|
||||
const CustomEventsMigration._();
|
||||
|
||||
@@ -57,17 +55,11 @@ class CustomEventsMigration {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> _isDone() async {
|
||||
final data = await Localstore.instance
|
||||
.collection(_collection)
|
||||
.doc(_document)
|
||||
.get();
|
||||
return data != null && data[_doneKey] == true;
|
||||
}
|
||||
// SharedPreferences, like the old cache document, is cleared on sign-out,
|
||||
// so the next account runs its own migration.
|
||||
static Future<bool> _isDone() async =>
|
||||
(await SharedPreferences.getInstance()).getBool(_doneKey) ?? false;
|
||||
|
||||
static Future<void> _markDone() async {
|
||||
await Localstore.instance.collection(_collection).doc(_document).set({
|
||||
_doneKey: true,
|
||||
});
|
||||
}
|
||||
static Future<void> _markDone() async =>
|
||||
(await SharedPreferences.getInstance()).setBool(_doneKey, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user