mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00

* feat: add playback history provider * feat: implement recently played section * refactor: use route names * feat: add stats summary and top tracks/artists/albums * feat: add top date based filtering * feat: add stream money calculation * refactor: place search in mobile navbar and settings in home appbar * feat: add individual minutes and streams page * feat(stats): add individual minutes and streams page * chore: default period to 1 month * feat: add text to explain user how hypothetical fees are calculated * chore: ensure usage of route names instead of direct paths * cd: add cache key * cd: remove media_kit_event_loop from git
41 lines
1.3 KiB
Dart
41 lines
1.3 KiB
Dart
part of 'connect.dart';
|
|
|
|
List<Map<String, dynamic>> _tracksJson(List<Track> tracks) {
|
|
return tracks.map((e) => e.toJson()).toList();
|
|
}
|
|
|
|
@freezed
|
|
class WebSocketLoadEventData with _$WebSocketLoadEventData {
|
|
const WebSocketLoadEventData._();
|
|
|
|
factory WebSocketLoadEventData.playlist({
|
|
@JsonKey(name: 'tracks', toJson: _tracksJson) required List<Track> tracks,
|
|
PlaylistSimple? collection,
|
|
int? initialIndex,
|
|
}) = WebSocketLoadEventDataPlaylist;
|
|
|
|
factory WebSocketLoadEventData.album({
|
|
@JsonKey(name: 'tracks', toJson: _tracksJson) required List<Track> tracks,
|
|
AlbumSimple? collection,
|
|
int? initialIndex,
|
|
}) = WebSocketLoadEventDataAlbum;
|
|
|
|
factory WebSocketLoadEventData.fromJson(Map<String, dynamic> json) =>
|
|
_$WebSocketLoadEventDataFromJson(json);
|
|
|
|
String? get collectionId => when(
|
|
playlist: (tracks, collection, _) => collection?.id,
|
|
album: (tracks, collection, _) => collection?.id,
|
|
);
|
|
}
|
|
|
|
class WebSocketLoadEvent extends WebSocketEvent<WebSocketLoadEventData> {
|
|
WebSocketLoadEvent(WebSocketLoadEventData data) : super(WsEvent.load, data);
|
|
|
|
factory WebSocketLoadEvent.fromJson(Map<String, dynamic> json) {
|
|
return WebSocketLoadEvent(
|
|
WebSocketLoadEventData.fromJson(json['data'] as Map<String, dynamic>),
|
|
);
|
|
}
|
|
}
|