mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
32 lines
1.0 KiB
Dart
32 lines
1.0 KiB
Dart
part of '../database.dart';
|
|
|
|
enum HistoryEntryType {
|
|
playlist,
|
|
album,
|
|
track,
|
|
}
|
|
|
|
class HistoryTable extends Table {
|
|
IntColumn get id => integer().autoIncrement()();
|
|
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
|
TextColumn get type => textEnum<HistoryEntryType>()();
|
|
TextColumn get itemId => text()();
|
|
TextColumn get data =>
|
|
text().map(const MapTypeConverter<String, dynamic>())();
|
|
}
|
|
|
|
extension HistoryItemParseExtension on HistoryTableData {
|
|
SpotubeSimplePlaylistObject? get playlist =>
|
|
type == HistoryEntryType.playlist && !data.containsKey("external_urls")
|
|
? SpotubeSimplePlaylistObject.fromJson(data)
|
|
: null;
|
|
SpotubeSimpleAlbumObject? get album =>
|
|
type == HistoryEntryType.album && !data.containsKey("external_urls")
|
|
? SpotubeSimpleAlbumObject.fromJson(data)
|
|
: null;
|
|
SpotubeTrackObject? get track =>
|
|
type == HistoryEntryType.track && !data.containsKey("external_urls")
|
|
? SpotubeTrackObject.fromJson(data)
|
|
: null;
|
|
}
|