mirror of
https://gitlab.com/foxixus/neomovies_mobile.git
synced 2025-10-28 01:18:50 +05:00
Compare commits
2 Commits
dfebd7f9e6
...
a9fcba5ca0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9fcba5ca0 | ||
|
|
185980083a |
@@ -36,15 +36,23 @@ class DownloadsProvider with ChangeNotifier {
|
|||||||
|
|
||||||
/// Загрузить список активных загрузок
|
/// Загрузить список активных загрузок
|
||||||
Future<void> refreshDownloads() async {
|
Future<void> refreshDownloads() async {
|
||||||
|
print('📥 DownloadsProvider: refreshDownloads() called');
|
||||||
try {
|
try {
|
||||||
|
print('📥 Setting loading=true, error=null');
|
||||||
_setLoading(true);
|
_setLoading(true);
|
||||||
_setError(null);
|
_setError(null);
|
||||||
|
|
||||||
|
print('📥 Calling TorrentPlatformService.getAllDownloads()...');
|
||||||
final progress = await TorrentPlatformService.getAllDownloads();
|
final progress = await TorrentPlatformService.getAllDownloads();
|
||||||
|
print('📥 Got ${progress.length} torrents from platform service');
|
||||||
|
|
||||||
// Получаем полную информацию о каждом торренте
|
// Получаем полную информацию о каждом торренте
|
||||||
_torrents.clear();
|
_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 {
|
try {
|
||||||
final torrentInfo = await TorrentPlatformService.getTorrent(progressItem.infoHash);
|
final torrentInfo = await TorrentPlatformService.getTorrent(progressItem.infoHash);
|
||||||
if (torrentInfo != null) {
|
if (torrentInfo != null) {
|
||||||
@@ -64,14 +72,22 @@ class DownloadsProvider with ChangeNotifier {
|
|||||||
state: progressItem.state,
|
state: progressItem.state,
|
||||||
savePath: '/storage/emulated/0/Download/NeoMovies',
|
savePath: '/storage/emulated/0/Download/NeoMovies',
|
||||||
files: [],
|
files: [],
|
||||||
));
|
);
|
||||||
|
print('📥 ✅ Created basic info: ${basicInfo.name}');
|
||||||
|
_torrents.add(basicInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print('📥 Final torrents count: ${_torrents.length}');
|
||||||
|
print('📥 Setting loading=false');
|
||||||
_setLoading(false);
|
_setLoading(false);
|
||||||
} catch (e) {
|
print('📥 ✅ refreshDownloads() completed successfully');
|
||||||
_setError(e.toString());
|
} catch (e, stackTrace) {
|
||||||
|
print('📥 ❌ Error refreshing downloads: $e');
|
||||||
|
print('📥 Stack trace: $stackTrace');
|
||||||
|
_setError(e.toString(), stackTrace.toString());
|
||||||
_setLoading(false);
|
_setLoading(false);
|
||||||
|
print('📥 Error state set, loading=false');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
print('📥 DownloadsScreen: initState() called');
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
print('📥 DownloadsScreen: postFrameCallback triggered');
|
||||||
|
print('📥 DownloadsScreen: calling refreshDownloads()');
|
||||||
context.read<DownloadsProvider>().refreshDownloads();
|
context.read<DownloadsProvider>().refreshDownloads();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -40,13 +43,20 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
|
|||||||
),
|
),
|
||||||
body: Consumer<DownloadsProvider>(
|
body: Consumer<DownloadsProvider>(
|
||||||
builder: (context, provider, child) {
|
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) {
|
if (provider.isLoading) {
|
||||||
|
print('📥 → Showing CircularProgressIndicator');
|
||||||
return const Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (provider.error != null) {
|
if (provider.error != null) {
|
||||||
|
print('📥 → Showing ErrorDisplay');
|
||||||
return ErrorDisplay(
|
return ErrorDisplay(
|
||||||
title: 'Ошибка загрузки торрентов',
|
title: 'Ошибка загрузки торрентов',
|
||||||
error: provider.error!,
|
error: provider.error!,
|
||||||
@@ -58,6 +68,7 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (provider.torrents.isEmpty) {
|
if (provider.torrents.isEmpty) {
|
||||||
|
print('📥 → Showing empty state');
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -87,6 +98,7 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print('📥 → Showing ${provider.torrents.length} torrents in list');
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await provider.refreshDownloads();
|
await provider.refreshDownloads();
|
||||||
|
|||||||
Reference in New Issue
Block a user