mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
28 lines
893 B
Dart
28 lines
893 B
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
|
|
? SpotubeSimplePlaylistObject.fromJson(data)
|
|
: null;
|
|
SpotubeSimpleAlbumObject? get album => type == HistoryEntryType.album
|
|
? SpotubeSimpleAlbumObject.fromJson(data)
|
|
: null;
|
|
SpotubeTrackObject? get track =>
|
|
type == HistoryEntryType.track ? SpotubeTrackObject.fromJson(data) : null;
|
|
}
|