From d872a3050627b67f1e3ad1b7ca6e3aa97f8be92d Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Sat, 9 May 2026 11:36:15 -0400 Subject: [PATCH] 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) --- flutter_client/lib/api/endpoints/me.dart | 11 +++++++++ .../lib/models/system_playlists_status.dart | 24 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 flutter_client/lib/models/system_playlists_status.dart 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?, + ); +}