chore: dart format

This commit is contained in:
edde746
2026-04-24 14:19:07 +02:00
parent 2479e1faaa
commit 2b59de91c7
22 changed files with 66 additions and 151 deletions
@@ -12,12 +12,7 @@ class AnilistSession {
final String? username;
final int createdAt;
const AnilistSession({
required this.accessToken,
required this.expiresAt,
required this.createdAt,
this.username,
});
const AnilistSession({required this.accessToken, required this.expiresAt, required this.createdAt, this.username});
bool get isExpired => DateTime.now().millisecondsSinceEpoch ~/ 1000 >= expiresAt;
@@ -50,11 +45,7 @@ class AnilistSession {
factory AnilistSession.fromProxyResult(OAuthProxyResult r) {
final createdAt = DateTime.now().millisecondsSinceEpoch ~/ 1000;
final expiresIn = r.expiresIn ?? 365 * 24 * 60 * 60;
return AnilistSession(
accessToken: r.accessToken,
expiresAt: createdAt + expiresIn,
createdAt: createdAt,
);
return AnilistSession(accessToken: r.accessToken, expiresAt: createdAt + expiresIn, createdAt: createdAt);
}
String encode() => json.encode(toJson());
@@ -16,8 +16,7 @@ import 'device_code_poller.dart' as poller;
abstract class DeviceCodeAuthServiceBase<T> {
final http.Client httpClient;
DeviceCodeAuthServiceBase({http.Client? httpClient})
: httpClient = httpClient ?? platform.createPlatformClient();
DeviceCodeAuthServiceBase({http.Client? httpClient}) : httpClient = httpClient ?? platform.createPlatformClient();
void dispose() => httpClient.close();
@@ -33,17 +32,10 @@ abstract class DeviceCodeAuthServiceBase<T> {
/// Drive the full flow. Invokes [onCodeReady] once with the code so the UI
/// can render the dialog, then polls until the user authorizes, denies, or
/// the code expires. Returns null on denied/expired/cancel.
Future<T?> authorize({
required void Function(DeviceCode code) onCodeReady,
bool Function()? shouldCancel,
}) async {
Future<T?> authorize({required void Function(DeviceCode code) onCodeReady, bool Function()? shouldCancel}) async {
final code = await createDeviceCode();
onCodeReady(code);
await for (final event in poller.pollDeviceCode(
code,
shouldCancel: shouldCancel,
probe: () => probe(code),
)) {
await for (final event in poller.pollDeviceCode(code, shouldCancel: shouldCancel, probe: () => probe(code))) {
if (event is DevicePollSuccess) return buildSession(event.tokenResponse);
if (event is DevicePollDenied || event is DevicePollExpired) return null;
}
@@ -156,10 +156,7 @@ class FribbMappingStore {
final client = platform.createPlatformClient();
try {
final res = await client
.get(
Uri.parse(_sourceUrl),
headers: {'If-None-Match': ?etag, 'Accept': 'application/json'},
)
.get(Uri.parse(_sourceUrl), headers: {'If-None-Match': ?etag, 'Accept': 'application/json'})
.timeout(_requestTimeout);
await prefs.setInt(_prefsLastCheckKey, now);
+3 -1
View File
@@ -127,7 +127,9 @@ class MalClient {
String? encoded;
if (formBody != null) {
headers['Content-Type'] = 'application/x-www-form-urlencoded';
encoded = formBody.entries.map((e) => '${Uri.encodeQueryComponent(e.key)}=${Uri.encodeQueryComponent(e.value)}').join('&');
encoded = formBody.entries
.map((e) => '${Uri.encodeQueryComponent(e.key)}=${Uri.encodeQueryComponent(e.value)}')
.join('&');
} else if (body != null) {
headers['Content-Type'] = 'application/json';
encoded = json.encode(body);
@@ -21,10 +21,7 @@ class SimklAuthService extends DeviceCodeAuthServiceBase<SimklSession> {
@override
Future<DeviceCode> createDeviceCode() async {
final uri = Uri.parse(SimklConstants.pinUrl).replace(
queryParameters: {
'client_id': SimklConstants.clientId,
'redirect': '${OAuthProxyClient.baseUrl}/auth/done',
},
queryParameters: {'client_id': SimklConstants.clientId, 'redirect': '${OAuthProxyClient.baseUrl}/auth/done'},
);
final res = await httpClient.get(uri, headers: SimklConstants.headers()).timeout(const Duration(seconds: 15));
if (res.statusCode != 200) {
@@ -17,11 +17,7 @@ class SimklSession {
createdAt: createdAt ?? this.createdAt,
);
Map<String, dynamic> toJson() => {
'access_token': accessToken,
'username': username,
'created_at': createdAt,
};
Map<String, dynamic> toJson() => {'access_token': accessToken, 'username': username, 'created_at': createdAt};
factory SimklSession.fromJson(Map<String, dynamic> json) => SimklSession(
accessToken: json['access_token'] as String,
+10 -14
View File
@@ -21,11 +21,7 @@ class TrackerCoordinator {
TrackerCoordinator._();
late final List<Tracker> _trackers = [
MalTracker.instance,
AnilistTracker.instance,
SimklTracker.instance,
];
late final List<Tracker> _trackers = [MalTracker.instance, AnilistTracker.instance, SimklTracker.instance];
/// Resolver persists across episode swaps so back-to-back episodes of the
/// same show reuse the cached IDs. Cleared only on profile switch.
@@ -113,16 +109,16 @@ class TrackerCoordinator {
}
Future<void> _dispatchMarkWatched(TrackerContext ctx) async {
final active = _trackers.where(
(t) => t.canScrobble && t.shouldScrobbleForLibrary(ctx.libraryGlobalKey),
final active = _trackers.where((t) => t.canScrobble && t.shouldScrobbleForLibrary(ctx.libraryGlobalKey));
await Future.wait(
active.map((t) async {
try {
await t.markWatched(ctx);
} catch (e) {
appLogger.d('${t.name}: markWatched failed', error: e);
}
}),
);
await Future.wait(active.map((t) async {
try {
await t.markWatched(ctx);
} catch (e) {
appLogger.d('${t.name}: markWatched failed', error: e);
}
}));
}
Future<TrackerContext?> _buildContext(PlexMetadata metadata) async {
@@ -34,12 +34,9 @@ class TrackerIdResolver {
/// un-matched item doesn't re-hit Plex every position update.
final Map<String, TrackerIds?> _cache = {};
TrackerIdResolver(
this._client, {
bool Function()? needsFribb,
FribbMappingStore? store,
}) : _needsFribb = needsFribb ?? _returnTrue,
_store = store ?? FribbMappingStore.instance;
TrackerIdResolver(this._client, {bool Function()? needsFribb, FribbMappingStore? store})
: _needsFribb = needsFribb ?? _returnTrue,
_store = store ?? FribbMappingStore.instance;
static bool _returnTrue() => true;