refactor: remove dead code across codebase
This commit is contained in:
@@ -27,7 +27,6 @@ class PlexFileInfo {
|
||||
final String? colorSpace;
|
||||
final String? colorRange;
|
||||
final String? colorPrimaries;
|
||||
final String? colorTrc;
|
||||
final String? chromaSubsampling;
|
||||
final double? frameRate;
|
||||
final int? bitDepth;
|
||||
@@ -59,7 +58,6 @@ class PlexFileInfo {
|
||||
this.colorSpace,
|
||||
this.colorRange,
|
||||
this.colorPrimaries,
|
||||
this.colorTrc,
|
||||
this.chromaSubsampling,
|
||||
this.frameRate,
|
||||
this.bitDepth,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:collection';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:plezy/utils/content_utils.dart';
|
||||
import '../models/download_models.dart';
|
||||
@@ -450,13 +449,6 @@ class DownloadProvider extends ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
/// Whether there are any downloads (active or completed)
|
||||
bool get hasDownloads => _downloads.isNotEmpty;
|
||||
|
||||
/// Whether there are any active downloads
|
||||
bool get hasActiveDownloads =>
|
||||
_downloads.values.any((p) => p.status == DownloadStatus.downloading || p.status == DownloadStatus.queued);
|
||||
|
||||
/// Get download progress for a specific item
|
||||
/// For shows/seasons, returns aggregate progress of all child episodes
|
||||
/// For episodes/movies, returns direct progress
|
||||
@@ -947,15 +939,9 @@ class DownloadProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Check if an item is being deleted
|
||||
bool isDeleting(String globalKey) => _deletionProgress.containsKey(globalKey);
|
||||
|
||||
/// Get deletion progress for an item
|
||||
DeletionProgress? getDeletionProgress(String globalKey) => _deletionProgress[globalKey];
|
||||
|
||||
/// Get all items currently being deleted
|
||||
UnmodifiableMapView<String, DeletionProgress> get deletionProgress => UnmodifiableMapView(_deletionProgress);
|
||||
|
||||
/// Refresh the downloads list from database
|
||||
Future<void> refresh() async {
|
||||
await _loadPersistedDownloads();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../i18n/strings.g.dart';
|
||||
import '../services/settings_service.dart';
|
||||
|
||||
class SettingsProvider extends ChangeNotifier {
|
||||
@@ -162,14 +161,4 @@ class SettingsProvider extends ChangeNotifier {
|
||||
persist: _settingsService!.setAutoHidePerformanceOverlay,
|
||||
);
|
||||
|
||||
String get episodePosterModeDisplayName {
|
||||
switch (_episodePosterMode) {
|
||||
case EpisodePosterMode.seriesPoster:
|
||||
return t.settings.seriesPoster;
|
||||
case EpisodePosterMode.seasonPoster:
|
||||
return t.settings.seasonPoster;
|
||||
case EpisodePosterMode.episodeThumbnail:
|
||||
return t.settings.episodeThumbnail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +49,7 @@ import '../widgets/companion_remote/remote_session_dialog.dart';
|
||||
import 'companion_remote/mobile_remote_screen.dart';
|
||||
|
||||
class DiscoverScreen extends StatefulWidget {
|
||||
final VoidCallback? onBecameVisible;
|
||||
|
||||
const DiscoverScreen({super.key, this.onBecameVisible});
|
||||
const DiscoverScreen({super.key});
|
||||
|
||||
@override
|
||||
State<DiscoverScreen> createState() => _DiscoverScreenState();
|
||||
|
||||
@@ -567,7 +567,7 @@ class _MainScreenState extends State<MainScreen> with RouteAware, WindowListener
|
||||
return [
|
||||
for (final tab in _getVisibleTabs(offline))
|
||||
switch (tab.id) {
|
||||
NavigationTabId.discover => DiscoverScreen(key: _discoverKey, onBecameVisible: _onDiscoverBecameVisible),
|
||||
NavigationTabId.discover => DiscoverScreen(key: _discoverKey),
|
||||
NavigationTabId.libraries => LibrariesScreen(key: _librariesKey, onLibraryOrderChanged: _onLibraryOrderChanged),
|
||||
NavigationTabId.liveTv => LiveTvScreen(key: _liveTvKey),
|
||||
NavigationTabId.search => SearchScreen(key: _searchKey),
|
||||
|
||||
@@ -17,7 +17,6 @@ class DisplayModeService {
|
||||
bool _displayModeChanged = false;
|
||||
bool _hdrStateChanged = false;
|
||||
|
||||
bool get displayModeChanged => _displayModeChanged;
|
||||
bool get hdrStateChanged => _hdrStateChanged;
|
||||
bool get anyChangeApplied => _displayModeChanged || _hdrStateChanged;
|
||||
|
||||
|
||||
@@ -1327,7 +1327,6 @@ class PlexClient {
|
||||
colorSpace: videoStream?['colorSpace'] as String?,
|
||||
colorRange: videoStream?['colorRange'] as String?,
|
||||
colorPrimaries: videoStream?['colorPrimaries'] as String?,
|
||||
colorTrc: videoStream?['colorTrc'] as String?,
|
||||
chromaSubsampling: videoStream?['chromaSubsampling'] as String?,
|
||||
frameRate: (videoStream?['frameRate'] as num?)?.toDouble(),
|
||||
bitDepth: videoStream?['bitDepth'] as int?,
|
||||
@@ -1804,31 +1803,6 @@ class PlexClient {
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Clear all items from a playlist
|
||||
Future<bool> clearPlaylist(String playlistId) {
|
||||
return _wrapBoolApiCall(() => _http.delete('/playlists/$playlistId/items'), 'Failed to clear playlist');
|
||||
}
|
||||
|
||||
/// Update playlist metadata (e.g., title, summary)
|
||||
/// Uses the same metadata editing mechanism as other items
|
||||
Future<bool> updatePlaylist({required String playlistId, String? title, String? summary}) {
|
||||
final queryParams = <String, dynamic>{'type': 'playlist', 'id': playlistId};
|
||||
|
||||
if (title != null) {
|
||||
queryParams['title.value'] = title;
|
||||
queryParams['title.locked'] = '1';
|
||||
}
|
||||
if (summary != null) {
|
||||
queryParams['summary.value'] = summary;
|
||||
queryParams['summary.locked'] = '1';
|
||||
}
|
||||
|
||||
return _wrapBoolApiCall(
|
||||
() => _http.put('/library/metadata/$playlistId', queryParameters: queryParams),
|
||||
'Failed to update playlist',
|
||||
);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Metadata Editing Methods
|
||||
// ============================================================================
|
||||
@@ -2122,23 +2096,6 @@ class PlexClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// Shuffle a play queue
|
||||
/// The currently selected item is maintained
|
||||
Future<PlayQueueResponse?> shufflePlayQueue(int playQueueId) async {
|
||||
try {
|
||||
final response = await _http.put('/playQueues/$playQueueId/shuffle');
|
||||
return PlayQueueResponse.fromJson(response.data);
|
||||
} catch (e) {
|
||||
appLogger.e('Failed to shuffle play queue: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear all items from a play queue
|
||||
Future<bool> clearPlayQueue(int playQueueId) {
|
||||
return _wrapBoolApiCall(() => _http.delete('/playQueues/$playQueueId/items'), 'Failed to clear play queue');
|
||||
}
|
||||
|
||||
/// Create a play queue for a TV show (all episodes)
|
||||
///
|
||||
/// This is a convenience method that creates a play queue from a show's URI.
|
||||
@@ -2305,62 +2262,6 @@ class PlexClient {
|
||||
await _getWithFailover('/library/sections/$sectionId/analyze');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Library Statistics Methods
|
||||
// ============================================================================
|
||||
|
||||
/// Get total item count for a library section efficiently.
|
||||
/// Uses X-Plex-Container-Size: 1 to get totalSize with minimal data transfer.
|
||||
Future<int> getLibraryTotalCount(String sectionId) async {
|
||||
try {
|
||||
final response = await _getWithFailover(
|
||||
'/library/sections/$sectionId/all',
|
||||
queryParameters: {'X-Plex-Container-Start': 0, 'X-Plex-Container-Size': 1},
|
||||
);
|
||||
final container = _getMediaContainer(response);
|
||||
// Try totalSize first, fall back to size if not available
|
||||
return container?['totalSize'] as int? ?? container?['size'] as int? ?? 0;
|
||||
} catch (e) {
|
||||
appLogger.e('Failed to get library total count: $e');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get total episode count for a TV show library.
|
||||
/// Uses the allLeaves endpoint to count all episodes.
|
||||
Future<int> getLibraryEpisodeCount(String sectionId) async {
|
||||
try {
|
||||
final response = await _getWithFailover(
|
||||
'/library/sections/$sectionId/allLeaves',
|
||||
queryParameters: {'X-Plex-Container-Start': 0, 'X-Plex-Container-Size': 1},
|
||||
);
|
||||
final container = _getMediaContainer(response);
|
||||
return container?['totalSize'] as int? ?? container?['size'] as int? ?? 0;
|
||||
} catch (e) {
|
||||
appLogger.e('Failed to get library episode count: $e');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get watch history count for a time period.
|
||||
/// [since] - Optional DateTime to filter history from this date onwards.
|
||||
/// Returns the total count of items watched.
|
||||
Future<int> getWatchHistoryCount({DateTime? since}) async {
|
||||
try {
|
||||
final queryParams = <String, dynamic>{'X-Plex-Container-Start': 0, 'X-Plex-Container-Size': 1};
|
||||
if (since != null) {
|
||||
final epochSeconds = since.millisecondsSinceEpoch ~/ 1000;
|
||||
queryParams['viewedAt>'] = epochSeconds;
|
||||
}
|
||||
final response = await _getWithFailover('/status/sessions/history/all', queryParameters: queryParams);
|
||||
final container = _getMediaContainer(response);
|
||||
return container?['totalSize'] as int? ?? container?['size'] as int? ?? 0;
|
||||
} catch (e) {
|
||||
appLogger.e('Failed to get watch history count: $e');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Live TV / DVR Methods
|
||||
// ============================================================================
|
||||
|
||||
@@ -19,35 +19,4 @@ class FocusUtils {
|
||||
});
|
||||
}
|
||||
|
||||
/// Execute a callback after the current frame completes, with mounted check.
|
||||
/// The callback will only execute if the State is still mounted.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```dart
|
||||
/// FocusUtils.afterBuildIfMounted(this, () {
|
||||
/// // do something
|
||||
/// });
|
||||
/// ```
|
||||
static void afterBuildIfMounted(State state, VoidCallback callback) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (state.mounted) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Execute a callback after the current frame completes, without mounted check.
|
||||
/// Use this when you don't need the mounted check or are managing it yourself.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```dart
|
||||
/// FocusUtils.afterBuild(() {
|
||||
/// // do something
|
||||
/// });
|
||||
/// ```
|
||||
static void afterBuild(VoidCallback callback) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,22 +54,6 @@ class ByteFormatter {
|
||||
return '${(kbps / 1000).toStringAsFixed(1)} Mbps';
|
||||
}
|
||||
|
||||
/// Format bitrate in bps to human-readable string
|
||||
///
|
||||
/// [bps] The bitrate in bits per second
|
||||
/// Returns formatted string like "8.5 Mbps", "256 Kbps", or "128 bps"
|
||||
static String formatBitrateBps(int bps) {
|
||||
const kbps = 1000;
|
||||
const mbps = kbps * 1000;
|
||||
|
||||
if (bps >= mbps) {
|
||||
return '${(bps / mbps).toStringAsFixed(2)} Mbps';
|
||||
} else if (bps >= kbps) {
|
||||
return '${(bps / kbps).toStringAsFixed(2)} Kbps';
|
||||
} else {
|
||||
return '$bps bps';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Formats a duration in human-readable textual format (e.g., "1h 23m" or "1 hour 23 minutes").
|
||||
|
||||
Reference in New Issue
Block a user