d872a30506
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>
42 lines
1.5 KiB
Dart
42 lines
1.5 KiB
Dart
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 {
|
|
MeApi(this._dio);
|
|
final Dio _dio;
|
|
|
|
/// GET /api/me/history. Paginated via offset/limit; server emits
|
|
/// `{events, has_more}` rather than the standard `Page<T>` envelope.
|
|
Future<HistoryPage> history({int limit = 50, int offset = 0}) async {
|
|
final r = await _dio.get<Map<String, dynamic>>(
|
|
'/api/me/history',
|
|
queryParameters: {'limit': limit, 'offset': offset},
|
|
);
|
|
return HistoryPage.fromJson(r.data ?? const {});
|
|
}
|
|
|
|
/// GET /api/quarantine/mine — flat list (no envelope).
|
|
Future<List<QuarantineMineRow>> quarantineMine() async {
|
|
final r = await _dio.get<List<dynamic>>('/api/quarantine/mine');
|
|
final raw = r.data ?? const [];
|
|
return raw
|
|
.map((e) =>
|
|
QuarantineMineRow.fromJson((e as Map).cast<String, dynamic>()))
|
|
.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 {});
|
|
}
|
|
}
|