improved performance and battery usage on older devices

This commit is contained in:
2026-09-25 23:58:08 +02:00
parent ed8e52f475
commit 56a497985b
70 changed files with 1631 additions and 621 deletions
+18 -9
View File
@@ -228,16 +228,25 @@ class AccountData {
Future<void> _migrateAndLoad() async {
await _migrateFromLegacyStorage();
await _migrateKeychainAccessibility();
_username = await _secureStorage.read(key: _usernameField);
_password = await _secureStorage.read(key: _passwordField);
_isDemo = (await _secureStorage.read(key: _demoField)) == 'true';
_usesLoginFlow =
(await _secureStorage.read(key: _loginFlowField)) == 'true';
// Independent keystore reads, each a platform-channel round trip with
// decryption: issued together since this gates the first frame.
final (username, password, demo, loginFlow) = await (
_secureStorage.read(key: _usernameField),
_secureStorage.read(key: _passwordField),
_secureStorage.read(key: _demoField),
_secureStorage.read(key: _loginFlowField),
).wait;
_username = username;
_password = password;
_isDemo = demo == 'true';
_usesLoginFlow = loginFlow == 'true';
try {
_appPassword = await pushSecureStorage.read(key: _appPasswordField);
_appPasswordTalk = await pushSecureStorage.read(
key: _appPasswordTalkField,
);
final (appPassword, appPasswordTalk) = await (
pushSecureStorage.read(key: _appPasswordField),
pushSecureStorage.read(key: _appPasswordTalkField),
).wait;
_appPassword = appPassword;
_appPasswordTalk = appPasswordTalk;
} on Object {
_appPassword = null;
_appPasswordTalk = null;
+3 -19
View File
@@ -1,24 +1,8 @@
import 'package:localstore/localstore.dart';
import '../api/request_cache.dart';
import '../api/cache_store.dart';
class DataCleaner {
static Future<void> cleanOldCache() async {
final cacheData = await Localstore.instance
.collection(RequestCache.collection)
.get();
cacheData?.forEach((key, value) async {
final lastUpdate = DateTime.fromMillisecondsSinceEpoch(
((value['lastupdate'] as num?) ?? 0).toInt(),
);
if (DateTime.now()
.subtract(const Duration(days: 200))
.isAfter(lastUpdate)) {
await Localstore.instance
.collection(RequestCache.collection)
.doc(key.split('/').last)
.delete();
}
});
await CacheStore.deleteLegacyLocalstoreCache();
await CacheStore.instance.deleteOlderThan(const Duration(days: 200));
}
}
+2 -2
View File
@@ -8,6 +8,7 @@ import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../api/cache_store.dart';
import '../api/marianumcloud/talk/share_files_to_chat.dart';
import '../background/widget_background_task.dart';
import '../notification/notification_service.dart';
@@ -26,7 +27,6 @@ import '../state/app/modules/timetable/bloc/timetable_bloc.dart';
import '../utils/app_paths.dart';
import '../utils/downloads/download_manager.dart';
import '../utils/file_clipboard.dart';
import '../widget/debug/cache_view.dart';
import '../widget_data/widget_sync.dart';
/// Removes everything the signed-out account left on the device. Every step
@@ -98,7 +98,7 @@ abstract final class SessionWipe {
await (await SharedPreferences.getInstance()).clear();
});
await _stepAsync('hydrated storage', HydratedBloc.storage.clear);
await _stepAsync('request cache', const CacheView().clear);
await _stepAsync('request cache', CacheStore.instance.clear);
await _stepAsync('chat background', () async {
final image = File(AppPaths.chatBackgroundImage);
if (image.existsSync()) await image.delete();