66545bf8c3
Models: - history_event.dart (HistoryEvent + HistoryPage envelope) - quarantine_mine.dart (QuarantineMineRow for /api/quarantine/mine) - Renamed Page<T> -> Paged<T> to avoid collision with Material's Page Endpoints: - library_lists.dart: listArtists / listAlbums (paged) - me.dart: history + quarantineMine - likes.dart: extended with listTracks/Albums/Artists (paged) UI: - library_screen.dart: TabBar over 5 tabs - Artists tab: 3-col grid - Albums tab: 2-col grid - History tab: list with relative-time formatting (matches HistoryRow.svelte) - Liked tab: 3 stacked sections (artists scroll-row, albums scroll-row, tracks list) - Hidden tab: list of quarantined tracks with reason pill - /library route + library_music icon on home AppBar First page only for v1 (limit 50). Infinite scroll deferred.
45 lines
1.3 KiB
Dart
45 lines
1.3 KiB
Dart
import 'track.dart';
|
|
|
|
/// Mirrors web/src/lib/api/history.ts HistoryEvent. Server emits
|
|
/// `{events, has_more}` rather than the standard `Page<T>` envelope —
|
|
/// history is timestamp-keyed so total isn't meaningful, only "more
|
|
/// pages exist below."
|
|
class HistoryEvent {
|
|
const HistoryEvent({
|
|
required this.id,
|
|
required this.playedAt,
|
|
required this.track,
|
|
});
|
|
|
|
final String id;
|
|
/// RFC3339 timestamp; UI formats relative ("3h ago" / "Tue 14:32" /
|
|
/// "May 1, 2025") via formatRelative helper.
|
|
final String playedAt;
|
|
final TrackRef track;
|
|
|
|
factory HistoryEvent.fromJson(Map<String, dynamic> j) => HistoryEvent(
|
|
id: j['id'] as String? ?? '',
|
|
playedAt: j['played_at'] as String? ?? '',
|
|
track: TrackRef.fromJson(
|
|
(j['track'] as Map?)?.cast<String, dynamic>() ?? const {},
|
|
),
|
|
);
|
|
}
|
|
|
|
class HistoryPage {
|
|
const HistoryPage({required this.events, required this.hasMore});
|
|
|
|
final List<HistoryEvent> events;
|
|
final bool hasMore;
|
|
|
|
factory HistoryPage.fromJson(Map<String, dynamic> j) {
|
|
final raw = (j['events'] as List?) ?? const [];
|
|
return HistoryPage(
|
|
events: raw
|
|
.map((e) => HistoryEvent.fromJson((e as Map).cast<String, dynamic>()))
|
|
.toList(growable: false),
|
|
hasMore: j['has_more'] as bool? ?? false,
|
|
);
|
|
}
|
|
}
|