Skip to content

Commit d203ae0

Browse files
committed
Resolved check hash issue
1 parent 06fcb87 commit d203ae0

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

lib/Api/torrent_api.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class TorrentApi {
310310
}
311311
}
312312

313-
static Future<void> checkTorrentHash({
313+
static Future<bool> checkTorrentHash({
314314
required List<String> hashes,
315315
required BuildContext context,
316316
}) async {
@@ -334,11 +334,17 @@ class TorrentApi {
334334
url,
335335
data: rawBody,
336336
);
337+
//if hashcheck is successful then return true else return false
337338
if (response.statusCode == 200) {
338-
} else {}
339+
return true;
340+
} else {
341+
return false;
342+
}
339343
} catch (e) {
340344
print('--ERROR--');
341345
print(e.toString());
346+
//if error arises then return false
347+
return false;
342348
}
343349
}
344350
}

lib/Components/torrent_tile.dart

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import 'package:flood_mobile/Route/Arguments/torrent_content_page_arguments.dart
88
import 'package:flood_mobile/Route/routes.dart';
99
import 'package:flood_mobile/Services/date_converter.dart';
1010
import 'package:flood_mobile/Services/file_size_helper.dart';
11+
import 'package:flutter/foundation.dart';
1112
import 'package:flutter/material.dart';
1213
import 'package:flutter_slidable/flutter_slidable.dart';
1314
import 'package:focused_menu/focused_menu.dart';
1415
import 'package:focused_menu/modals.dart';
1516
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
1617
import 'package:percent_indicator/linear_percent_indicator.dart';
1718

19+
import 'flood_snackbar.dart';
20+
1821
class TorrentTile extends StatefulWidget {
1922
final TorrentModel model;
2023

@@ -89,9 +92,30 @@ class _TorrentTileState extends State<TorrentTile> {
8992
Icons.tag,
9093
color: Colors.black,
9194
),
92-
onPressed: () {
93-
TorrentApi.checkTorrentHash(
95+
onPressed: () async {
96+
var result = await TorrentApi.checkTorrentHash(
9497
hashes: [widget.model.hash], context: context);
98+
if (result) {
99+
if(kDebugMode)
100+
print("check hash performed successfully");
101+
final addTorrentSnackbar = addFloodSnackBar(
102+
SnackbarType.success,
103+
'Hash check successful',
104+
'Dismiss');
105+
106+
ScaffoldMessenger.of(context)
107+
.showSnackBar(addTorrentSnackbar);
108+
} else {
109+
if(kDebugMode)
110+
print("Error check hash failed");
111+
final addTorrentSnackbar = addFloodSnackBar(
112+
SnackbarType.caution,
113+
'Torrent hash failed',
114+
'Dismiss');
115+
116+
ScaffoldMessenger.of(context)
117+
.showSnackBar(addTorrentSnackbar);
118+
}
95119
},
96120
),
97121
FocusedMenuItem(

0 commit comments

Comments
 (0)