refactor: remove dead code
This commit is contained in:
@@ -28,7 +28,4 @@ class PlexVideoPlaybackData {
|
||||
|
||||
/// Returns true if media info is available
|
||||
bool get hasMediaInfo => mediaInfo != null;
|
||||
|
||||
/// Returns true if there are multiple media versions available
|
||||
bool get hasMultipleVersions => availableVersions.length > 1;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,6 @@ import '../models/plex_metadata.dart';
|
||||
import '../models/play_queue_response.dart';
|
||||
import '../services/plex_client.dart';
|
||||
|
||||
/// Playback mode types
|
||||
///
|
||||
/// All playback now uses Plex play queues.
|
||||
enum PlaybackMode {
|
||||
playQueue, // Play queue-based playback (sequential, shuffle, playlists, collections)
|
||||
}
|
||||
|
||||
/// Result of trying to locate the current queue index.
|
||||
class _IndexLookupResult {
|
||||
final int? index;
|
||||
@@ -32,24 +25,20 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
List<PlexMetadata> _loadedItems = [];
|
||||
final int _windowSize = 50; // Number of items to keep in memory
|
||||
|
||||
// Legacy state for backward compatibility
|
||||
String? _contextKey; // The show/season/playlist ratingKey for this session
|
||||
PlaybackMode? _playbackMode;
|
||||
bool _isQueueMode = false;
|
||||
|
||||
// Client reference for loading more items
|
||||
PlexClient? _client;
|
||||
|
||||
/// Current playback mode (null if no queue active)
|
||||
PlaybackMode? get playbackMode => _playbackMode;
|
||||
|
||||
/// Whether shuffle mode is currently active
|
||||
bool get isShuffleActive => _playQueueShuffled;
|
||||
|
||||
/// Whether playlist/collection mode is currently active
|
||||
bool get isPlaylistActive => _playbackMode == PlaybackMode.playQueue;
|
||||
bool get isPlaylistActive => _isQueueMode;
|
||||
|
||||
/// Whether any queue-based playback is active
|
||||
bool get isQueueActive => _playQueueId != null && _playbackMode == PlaybackMode.playQueue;
|
||||
bool get isQueueActive => _playQueueId != null && _isQueueMode;
|
||||
|
||||
/// The context key (show/season/playlist ratingKey) for the current session
|
||||
String? get shuffleContextKey => _contextKey;
|
||||
@@ -63,9 +52,6 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
/// The current play queue item ID
|
||||
int? get currentPlayQueueItemID => _currentPlayQueueItemID;
|
||||
|
||||
/// Total number of items in the play queue
|
||||
int get queueLength => _playQueueTotalCount;
|
||||
|
||||
/// Set the client reference for loading more items
|
||||
void setClient(PlexClient client) {
|
||||
_client = client;
|
||||
@@ -73,7 +59,7 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
|
||||
/// Update the current play queue item when playing a new item
|
||||
void setCurrentItem(PlexMetadata metadata) {
|
||||
if (_playbackMode == PlaybackMode.playQueue && metadata.playQueueItemID != null) {
|
||||
if (_isQueueMode && metadata.playQueueItemID != null) {
|
||||
_currentPlayQueueItemID = metadata.playQueueItemID;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -92,7 +78,7 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
_loadedItems = playQueue.items ?? [];
|
||||
|
||||
_contextKey = contextKey;
|
||||
_playbackMode = PlaybackMode.playQueue;
|
||||
_isQueueMode = true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -132,7 +118,7 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<_IndexLookupResult> _getCurrentIndex({bool loadIfMissing = false}) async {
|
||||
if (_playbackMode != PlaybackMode.playQueue || _loadedItems.isEmpty || _currentPlayQueueItemID == null) {
|
||||
if (!_isQueueMode || _loadedItems.isEmpty || _currentPlayQueueItemID == null) {
|
||||
return const _IndexLookupResult();
|
||||
}
|
||||
|
||||
@@ -164,7 +150,7 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
/// Returns null if queue is exhausted or current item is not in queue.
|
||||
/// [loopQueue] - If true, restart from beginning when queue is exhausted
|
||||
Future<PlexMetadata?> getNextEpisode(String currentItemKey, {bool loopQueue = false}) async {
|
||||
if (_playbackMode != PlaybackMode.playQueue) {
|
||||
if (!_isQueueMode) {
|
||||
// For sequential mode, let the video player handle next episode
|
||||
return null;
|
||||
}
|
||||
@@ -221,7 +207,7 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
/// Gets the previous item in the playback queue.
|
||||
/// Returns null if at the beginning of the queue or current item is not in queue.
|
||||
Future<PlexMetadata?> getPreviousEpisode(String currentItemKey) async {
|
||||
if (_playbackMode != PlaybackMode.playQueue) {
|
||||
if (!_isQueueMode) {
|
||||
// For sequential mode, let the video player handle previous episode
|
||||
return null;
|
||||
}
|
||||
@@ -262,7 +248,7 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
_currentPlayQueueItemID = null;
|
||||
_loadedItems = [];
|
||||
_contextKey = null;
|
||||
_playbackMode = null;
|
||||
_isQueueMode = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,15 +315,6 @@ class PlexClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the token used by this client
|
||||
void updateToken(String newToken) {
|
||||
// Update both the Dio headers and the config to ensure consistency
|
||||
_dio.options.headers['X-Plex-Token'] = newToken;
|
||||
config = config.copyWith(token: newToken);
|
||||
LogRedactionManager.registerToken(newToken);
|
||||
appLogger.d('PlexClient token updated (headers and config)');
|
||||
}
|
||||
|
||||
/// Update endpoint priority list and optionally hop to the new best endpoint.
|
||||
Future<void> updateEndpointPreferences(List<String> prioritizedEndpoints, {bool switchToFirst = false}) async {
|
||||
if (_endpointManager == null || prioritizedEndpoints.isEmpty) {
|
||||
@@ -1058,36 +1049,6 @@ class PlexClient {
|
||||
[];
|
||||
}
|
||||
|
||||
/// Get all unwatched episodes for a TV show across all seasons
|
||||
Future<List<PlexMetadata>> getAllUnwatchedEpisodes(String showRatingKey) async {
|
||||
final allEpisodes = <PlexMetadata>[];
|
||||
|
||||
// Get all seasons for the show
|
||||
final seasons = await getChildren(showRatingKey);
|
||||
|
||||
// Get episodes from each season
|
||||
for (final season in seasons) {
|
||||
if (season.isSeason) {
|
||||
final episodes = await getChildren(season.ratingKey);
|
||||
|
||||
// Filter for unwatched episodes
|
||||
final unwatchedEpisodes = episodes.where((ep) => ep.isEpisode && (ep.viewCount ?? 0) == 0).toList();
|
||||
|
||||
allEpisodes.addAll(unwatchedEpisodes);
|
||||
}
|
||||
}
|
||||
|
||||
return allEpisodes;
|
||||
}
|
||||
|
||||
/// Get all unwatched episodes in a specific season
|
||||
Future<List<PlexMetadata>> getUnwatchedEpisodesInSeason(String seasonRatingKey) async {
|
||||
final episodes = await getChildren(seasonRatingKey);
|
||||
|
||||
// Filter for unwatched episodes
|
||||
return episodes.where((ep) => ep.isEpisode && (ep.viewCount ?? 0) == 0).toList();
|
||||
}
|
||||
|
||||
/// Get thumbnail URL
|
||||
String getThumbnailUrl(String? thumbPath) {
|
||||
if (thumbPath == null || thumbPath.isEmpty) return '';
|
||||
@@ -1384,12 +1345,6 @@ class PlexClient {
|
||||
return _wrapBoolApiCall(() => _dio.delete('/library/metadata/$ratingKey'), 'Failed to delete media item');
|
||||
}
|
||||
|
||||
/// Get server preferences
|
||||
Future<Map<String, dynamic>> getServerPreferences() async {
|
||||
final response = await _dio.get('/:/prefs');
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/// Get preferences for a library section.
|
||||
///
|
||||
/// Returns a map of setting id --> value for all settings in the library.
|
||||
@@ -1403,16 +1358,6 @@ class PlexClient {
|
||||
return {for (final s in list) s['id'] as String: s['value']};
|
||||
}
|
||||
|
||||
/// Get sessions (currently playing)
|
||||
Future<List<dynamic>> getSessions() async {
|
||||
final response = await _dio.get('/status/sessions');
|
||||
final container = _getMediaContainer(response);
|
||||
if (container != null && container['Metadata'] != null) {
|
||||
return container['Metadata'] as List;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/// Get available filters for a library section
|
||||
Future<List<PlexFilter>> getLibraryFilters(String sectionId) async {
|
||||
if (sectionId == 'shared') return [];
|
||||
|
||||
@@ -761,15 +761,6 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
return preferences[seriesRatingKey];
|
||||
}
|
||||
|
||||
/// Clear media version preference for a series
|
||||
Future<void> clearMediaVersionPreference(String seriesRatingKey) async {
|
||||
final preferences = _getMediaVersionPreferences();
|
||||
preferences.remove(seriesRatingKey);
|
||||
|
||||
final jsonString = json.encode(preferences);
|
||||
await prefs.setString(_keyMediaVersionPreferences, jsonString);
|
||||
}
|
||||
|
||||
/// Get all media version preferences
|
||||
Map<String, int> _getMediaVersionPreferences() {
|
||||
final jsonString = prefs.getString(_keyMediaVersionPreferences);
|
||||
|
||||
@@ -38,10 +38,6 @@ class DownloadTreeNode {
|
||||
return children.where((child) => child.status == DownloadStatus.completed).length;
|
||||
}
|
||||
|
||||
/// Get the number of downloading children
|
||||
int get downloadingChildrenCount {
|
||||
return children.where((child) => child.status == DownloadStatus.downloading).length;
|
||||
}
|
||||
}
|
||||
|
||||
/// Type of node in the download tree
|
||||
|
||||
Reference in New Issue
Block a user