Consolidates duplicated logic behind shared implementations — paginated grid tabs, focus chrome, cached remote stores, sheet selection columns, the server artifact store and a test fixture layer — and removes code that had become unreachable. Net reduction of about 5,500 lines with no behaviour change. Where a fix had landed separately in code that moved into a shared helper, the fix was re-applied inside the helper rather than left behind in the copy that went away.
76 lines
2.5 KiB
Dart
76 lines
2.5 KiB
Dart
/// Backend-neutral classification of a media item.
|
|
///
|
|
/// Mirrors the categories in [PlexMediaType] but is the canonical type used by
|
|
/// neutral domain models. Each backend's adapter is responsible for mapping
|
|
/// its own type strings (Plex `type` field, Jellyfin `BaseItemKind`) into one
|
|
/// of these values.
|
|
enum MediaKind {
|
|
movie,
|
|
show,
|
|
season,
|
|
episode,
|
|
artist,
|
|
album,
|
|
track,
|
|
collection,
|
|
playlist,
|
|
clip,
|
|
photo,
|
|
|
|
/// Filesystem-style directory row in folder browsing (Plex `/folder`
|
|
/// listings, Jellyfin `Folder`/`CollectionFolder` items). Not playable
|
|
/// media itself — children are fetched via
|
|
/// `MediaServerClient.fetchFolderChildren`.
|
|
folder,
|
|
unknown;
|
|
|
|
bool get isVideo => this == movie || this == episode || this == clip;
|
|
|
|
bool get isMusic => this == artist || this == album || this == track;
|
|
|
|
bool get isPlayable => isVideo || this == track;
|
|
|
|
/// Whether this container kind derives watched state from aggregate leaves.
|
|
bool get usesLeafWatchCounts => switch (this) {
|
|
show || season || artist || album || collection || playlist || folder => true,
|
|
movie || episode || track || clip || photo || unknown => false,
|
|
};
|
|
|
|
/// Lowercase string id used when persisting or comparing legacy code paths
|
|
/// that still hold raw type strings.
|
|
String get id => switch (this) {
|
|
MediaKind.movie => 'movie',
|
|
MediaKind.show => 'show',
|
|
MediaKind.season => 'season',
|
|
MediaKind.episode => 'episode',
|
|
MediaKind.artist => 'artist',
|
|
MediaKind.album => 'album',
|
|
MediaKind.track => 'track',
|
|
MediaKind.collection => 'collection',
|
|
MediaKind.playlist => 'playlist',
|
|
MediaKind.clip => 'clip',
|
|
MediaKind.photo => 'photo',
|
|
MediaKind.folder => 'folder',
|
|
MediaKind.unknown => 'unknown',
|
|
};
|
|
|
|
static MediaKind fromString(String? raw) {
|
|
if (raw == null) return MediaKind.unknown;
|
|
return switch (raw.toLowerCase()) {
|
|
'movie' => MediaKind.movie,
|
|
'show' || 'series' => MediaKind.show,
|
|
'season' => MediaKind.season,
|
|
'episode' => MediaKind.episode,
|
|
'artist' || 'musicartist' => MediaKind.artist,
|
|
'album' || 'musicalbum' => MediaKind.album,
|
|
'track' || 'audio' => MediaKind.track,
|
|
'collection' || 'boxset' => MediaKind.collection,
|
|
'playlist' => MediaKind.playlist,
|
|
'clip' || 'trailer' || 'video' || 'musicvideo' => MediaKind.clip,
|
|
'photo' => MediaKind.photo,
|
|
'folder' || 'collectionfolder' => MediaKind.folder,
|
|
_ => MediaKind.unknown,
|
|
};
|
|
}
|
|
}
|