Skip to content

Commit

Permalink
show sync button immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaphasilor committed Dec 6, 2023
1 parent 98091e0 commit a6a4121
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/components/AlbumScreen/sync_album_or_playlist_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,27 @@ class SyncAlbumOrPlaylistButton extends StatefulWidget {
class _SyncAlbumOrPlaylistButtonState
extends State<SyncAlbumOrPlaylistButton> {
final _syncLogger = Logger("SyncPlaylistButton");
final _downloadHelper = GetIt.instance<DownloadsHelper>();
bool isAlbumDownloaded = false;


void syncAlbumOrPlaylist() async {
_syncLogger.info("Syncing playlist");

var syncHelper = DownloadsSyncHelper(_syncLogger);
syncHelper.sync(widget.parent, widget.items);
setState(() {
isAlbumDownloaded = _downloadHelper.isAlbumDownloaded(widget.parent.id);
});
}

@override
Widget build(BuildContext context) {
final isAlbumDownloaded = GetIt.instance<DownloadsHelper>().isAlbumDownloaded(widget.parent.id);
isAlbumDownloaded = _downloadHelper.isAlbumDownloaded(widget.parent.id);
return IconButton(
onPressed: () => syncAlbumOrPlaylist(), icon:
isAlbumDownloaded ?
const Icon(Icons.sync) :
const Icon(Icons.download));
}
}
}

0 comments on commit a6a4121

Please sign in to comment.