diff --git a/flutter_client/lib/api/endpoints/me.dart b/flutter_client/lib/api/endpoints/me.dart index dd98bb06..3d5656ab 100644 --- a/flutter_client/lib/api/endpoints/me.dart +++ b/flutter_client/lib/api/endpoints/me.dart @@ -2,6 +2,7 @@ import 'package:dio/dio.dart'; import '../../models/history_event.dart'; import '../../models/quarantine_mine.dart'; +import '../../models/system_playlists_status.dart'; /// /api/me/* endpoints — caller-scoped data (history, profile, etc.). class MeApi { @@ -27,4 +28,14 @@ class MeApi { QuarantineMineRow.fromJson((e as Map).cast())) .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() async { + final r = await _dio.get>( + '/api/me/system-playlists-status', + ); + return SystemPlaylistsStatus.fromJson(r.data ?? const {}); + } } diff --git a/flutter_client/lib/models/system_playlists_status.dart b/flutter_client/lib/models/system_playlists_status.dart new file mode 100644 index 00000000..b8588196 --- /dev/null +++ b/flutter_client/lib/models/system_playlists_status.dart @@ -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 j) => + SystemPlaylistsStatus( + inFlight: j['in_flight'] as bool? ?? false, + lastRunAt: j['last_run_at'] as String?, + lastError: j['last_error'] as String?, + ); +}