mirror of
https://gitlab.com/foxixus/neomovies_mobile.git
synced 2025-10-27 17:58:50 +05:00
feat: add comprehensive logging for downloads debugging
Added extensive logging throughout DownloadsProvider and DownloadsScreen to diagnose why downloads screen appears empty. DownloadsProvider.refreshDownloads(): - 📥 Log function call - 📥 Log state changes (loading, error) - 📥 Log TorrentPlatformService.getAllDownloads() call - 📥 Log number of torrents received - 📥 Log each torrent processing with index - 📥 Log success/failure for each torrent info fetch - 📥 Log final torrents count - 📥 Log completion or error state DownloadsScreen.initState() and Consumer: - 📥 Log initState call - 📥 Log postFrameCallback execution - 📥 Log Consumer builder invocations - 📥 Log provider state (isLoading, error, torrents.length) - 📥 Log which UI is displayed: * CircularProgressIndicator * ErrorDisplay * Empty state message * Torrent list with count All logs prefixed with 📥 for easy filtering in logcat. Example output: --- 📥 DownloadsScreen: initState() called 📥 DownloadsScreen: postFrameCallback, calling refreshDownloads() 📥 DownloadsProvider: refreshDownloads() called 📥 Setting loading=true, error=null 📥 Calling TorrentPlatformService.getAllDownloads()... 📥 Got 0 torrents from platform service 📥 Cleared _torrents list 📥 Final torrents count: 0 📥 Setting loading=false 📥 ✅ refreshDownloads() completed successfully 📥 DownloadsScreen: Consumer builder called 📥 isLoading: false 📥 error: null 📥 torrents.length: 0 📥 → Showing empty state This will help identify: - Is refreshDownloads being called? - Does TorrentPlatformService return any data? - Are torrents parsed correctly? - Is the correct UI state shown? - Where does the process fail? Usage: Run app → Open Downloads screen → Check logcat for 📥 logs
This commit is contained in:
@@ -36,15 +36,23 @@ class DownloadsProvider with ChangeNotifier {
|
||||
|
||||
/// Загрузить список активных загрузок
|
||||
Future<void> refreshDownloads() async {
|
||||
print('📥 DownloadsProvider: refreshDownloads() called');
|
||||
try {
|
||||
print('📥 Setting loading=true, error=null');
|
||||
_setLoading(true);
|
||||
_setError(null);
|
||||
|
||||
print('📥 Calling TorrentPlatformService.getAllDownloads()...');
|
||||
final progress = await TorrentPlatformService.getAllDownloads();
|
||||
print('📥 Got ${progress.length} torrents from platform service');
|
||||
|
||||
// Получаем полную информацию о каждом торренте
|
||||
_torrents.clear();
|
||||
for (final progressItem in progress) {
|
||||
print('📥 Cleared _torrents list');
|
||||
|
||||
for (int i = 0; i < progress.length; i++) {
|
||||
final progressItem = progress[i];
|
||||
print('📥 Processing torrent $i: ${progressItem.infoHash.substring(0, 8)}...');
|
||||
try {
|
||||
final torrentInfo = await TorrentPlatformService.getTorrent(progressItem.infoHash);
|
||||
if (torrentInfo != null) {
|
||||
@@ -64,14 +72,22 @@ class DownloadsProvider with ChangeNotifier {
|
||||
state: progressItem.state,
|
||||
savePath: '/storage/emulated/0/Download/NeoMovies',
|
||||
files: [],
|
||||
));
|
||||
);
|
||||
print('📥 ✅ Created basic info: ${basicInfo.name}');
|
||||
_torrents.add(basicInfo);
|
||||
}
|
||||
}
|
||||
|
||||
print('📥 Final torrents count: ${_torrents.length}');
|
||||
print('📥 Setting loading=false');
|
||||
_setLoading(false);
|
||||
} catch (e) {
|
||||
_setError(e.toString());
|
||||
print('📥 ✅ refreshDownloads() completed successfully');
|
||||
} catch (e, stackTrace) {
|
||||
print('📥 ❌ Error refreshing downloads: $e');
|
||||
print('📥 Stack trace: $stackTrace');
|
||||
_setError(e.toString(), stackTrace.toString());
|
||||
_setLoading(false);
|
||||
print('📥 Error state set, loading=false');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,13 +40,20 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
|
||||
),
|
||||
body: Consumer<DownloadsProvider>(
|
||||
builder: (context, provider, child) {
|
||||
print('📥 DownloadsScreen: Consumer builder called');
|
||||
print('📥 isLoading: ${provider.isLoading}');
|
||||
print('📥 error: ${provider.error}');
|
||||
print('📥 torrents.length: ${provider.torrents.length}');
|
||||
|
||||
if (provider.isLoading) {
|
||||
print('📥 → Showing CircularProgressIndicator');
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
if (provider.error != null) {
|
||||
print('📥 → Showing ErrorDisplay');
|
||||
return ErrorDisplay(
|
||||
title: 'Ошибка загрузки торрентов',
|
||||
error: provider.error!,
|
||||
@@ -58,6 +65,7 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
|
||||
}
|
||||
|
||||
if (provider.torrents.isEmpty) {
|
||||
print('📥 → Showing empty state');
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -87,6 +95,7 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
print('📥 → Showing ${provider.torrents.length} torrents in list');
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await provider.refreshDownloads();
|
||||
|
||||
Reference in New Issue
Block a user