improved performance and battery usage on older devices

This commit is contained in:
MineTec committed 2026-09-25 23:58:08 +02:00
1 parent ed8e52f475
commit 56a497985b
70 files changed
+1631 -621

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import '../model/account_data.dart';
/// Joins concurrent calls into the one already running for the same account
/// session. A run left over from a signed-out session never blocks the next
/// account's first call.
class SessionSingleFlight {
Future<void>? _running;
int? _epoch;
Future<void> run(Future<void> Function() action) {
final epoch = AccountData().sessionEpoch;
final running = _running;
if (running != null && _epoch == epoch) return running;
_epoch = epoch;
late final Future<void> current;
current = action().whenComplete(() {
if (identical(_running, current)) _running = null;
});
return _running = current;
}
}