Files
plezy/lib/services/trackers/tracker_session_utils.dart
T
edde746 352b88109b refactor: extract shared mixins and helpers, drop dead abstractions
Introduces shared seams for paginated views, D-pad reorder, media control
routing, async singletons and the device method channel, then points the
open-coded copies at them.

Also removes unused models and duplicated provider/server plumbing, folds
the twice-implemented artifact store in the server, and factors the
repeated Flutter toolchain prologue in CI into a composite action.
2026-07-26 06:09:48 +02:00

17 lines
770 B
Dart

import 'dart:convert' as convert;
/// Current epoch time in seconds, matching tracker OAuth expiry fields.
int trackerSessionNowEpochSeconds() => DateTime.now().millisecondsSinceEpoch ~/ 1000;
bool isTrackerTokenExpired(int expiresAt, {int? nowSeconds}) =>
(nowSeconds ?? trackerSessionNowEpochSeconds()) >= expiresAt;
bool trackerTokenNeedsRefresh(int expiresAt, {int refreshWindowSeconds = 300, int? nowSeconds}) =>
(nowSeconds ?? trackerSessionNowEpochSeconds()) >= expiresAt - refreshWindowSeconds;
String encodeTrackerSessionJson(Map<String, dynamic> value) => convert.json.encode(value);
T decodeTrackerSessionJson<T>(String raw, T Function(Map<String, dynamic> json) fromJson) {
return fromJson(convert.json.decode(raw) as Map<String, dynamic>);
}