feat(flutter): SystemPlaylistsStatus model + endpoint method
Adds the model + MeApi.systemPlaylistsStatus() for the home Playlists row's placeholder-variant logic (building / failed / pending / seed-needed). Mirrors GET /api/me/system-playlists-status which returns the caller's most recent system_playlist_runs row. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:dio/dio.dart';
|
|||||||
|
|
||||||
import '../../models/history_event.dart';
|
import '../../models/history_event.dart';
|
||||||
import '../../models/quarantine_mine.dart';
|
import '../../models/quarantine_mine.dart';
|
||||||
|
import '../../models/system_playlists_status.dart';
|
||||||
|
|
||||||
/// /api/me/* endpoints — caller-scoped data (history, profile, etc.).
|
/// /api/me/* endpoints — caller-scoped data (history, profile, etc.).
|
||||||
class MeApi {
|
class MeApi {
|
||||||
@@ -27,4 +28,14 @@ class MeApi {
|
|||||||
QuarantineMineRow.fromJson((e as Map).cast<String, dynamic>()))
|
QuarantineMineRow.fromJson((e as Map).cast<String, dynamic>()))
|
||||||
.toList(growable: false);
|
.toList(growable: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// GET /api/me/system-playlists-status. Returns the caller's most
|
||||||
|
/// recent system-playlist build state. Used by the home Playlists
|
||||||
|
/// row to choose between real and placeholder cards.
|
||||||
|
Future<SystemPlaylistsStatus> systemPlaylistsStatus() async {
|
||||||
|
final r = await _dio.get<Map<String, dynamic>>(
|
||||||
|
'/api/me/system-playlists-status',
|
||||||
|
);
|
||||||
|
return SystemPlaylistsStatus.fromJson(r.data ?? const {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/// Mirrors `systemPlaylistsStatusResp` from internal/api/me_system_playlists.go.
|
||||||
|
/// Reflects the caller's most recent system_playlist_runs row, or zero
|
||||||
|
/// values when no row exists yet (the user has never had a build attempted).
|
||||||
|
class SystemPlaylistsStatus {
|
||||||
|
const SystemPlaylistsStatus({
|
||||||
|
required this.inFlight,
|
||||||
|
this.lastRunAt,
|
||||||
|
this.lastError,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool inFlight;
|
||||||
|
final String? lastRunAt;
|
||||||
|
final String? lastError;
|
||||||
|
|
||||||
|
factory SystemPlaylistsStatus.empty() =>
|
||||||
|
const SystemPlaylistsStatus(inFlight: false);
|
||||||
|
|
||||||
|
factory SystemPlaylistsStatus.fromJson(Map<String, dynamic> j) =>
|
||||||
|
SystemPlaylistsStatus(
|
||||||
|
inFlight: j['in_flight'] as bool? ?? false,
|
||||||
|
lastRunAt: j['last_run_at'] as String?,
|
||||||
|
lastError: j['last_error'] as String?,
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user