Skip to content

Commit 79b5002

Browse files
committed
fix: Display only one snackbar on duplicated torrent
1 parent c0ca882 commit 79b5002

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

app/lib/dialogs/add_torrent.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ class _AddTorrentDialogState extends State<AddTorrentDialog> {
3030
@override
3131
void initState() {
3232
super.initState();
33-
_torrentLinkController =
34-
TextEditingController();
33+
_torrentLinkController = TextEditingController();
3534

3635
_torrentLinkController.addListener(() {
3736
setState(() {
3837
_torrentLink = _torrentLinkController.text;
3938
});
4039
});
4140

42-
if(widget.initialMagnetLink != null) {
41+
if (widget.initialMagnetLink != null) {
4342
_torrentLinkController.text = widget.initialMagnetLink!;
4443
}
4544

@@ -69,20 +68,20 @@ class _AddTorrentDialogState extends State<AddTorrentDialog> {
6968
metainfo = base64Encode(content);
7069
}
7170
}
72-
var status = await Provider.of<TorrentsModel>(context, listen: false).addTorrent(
73-
_torrentLinkController.text, metainfo, pickedDownloadDir);
71+
var status = await Provider.of<TorrentsModel>(context, listen: false)
72+
.addTorrent(_torrentLinkController.text, metainfo, pickedDownloadDir);
7473

7574
if (status == TorrentAddedResponse.duplicated) {
7675
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
7776
content: Text('Torrent already added.'),
7877
backgroundColor: Colors.lightGreen,
7978
));
79+
} else {
80+
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
81+
content: Text('Torrent added.'),
82+
backgroundColor: Colors.lightGreen,
83+
));
8084
}
81-
82-
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
83-
content: Text('Torrent added.'),
84-
backgroundColor: Colors.lightGreen,
85-
));
8685
} on TorrentAddError {
8786
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
8887
content: Text('Invalid torrent.'),

0 commit comments

Comments
 (0)