diff --git a/lib/components/AlbumScreen/song_list_tile.dart b/lib/components/AlbumScreen/song_list_tile.dart index 77058a47b..385d4ec45 100644 --- a/lib/components/AlbumScreen/song_list_tile.dart +++ b/lib/components/AlbumScreen/song_list_tile.dart @@ -239,20 +239,22 @@ class _SongListTileState extends State { screenSize.height - details.globalPosition.dy, ), items: [ - PopupMenuItem( - value: SongListTileMenuItems.addToQueue, - child: ListTile( - leading: const Icon(Icons.queue_music), - title: Text(AppLocalizations.of(context)!.addToQueue), + if (_audioServiceHelper.hasQueueItems()) ...[ + PopupMenuItem( + value: SongListTileMenuItems.addToQueue, + child: ListTile( + leading: const Icon(Icons.queue_music), + title: Text(AppLocalizations.of(context)!.addToQueue), + ), ), - ), - PopupMenuItem( - value: SongListTileMenuItems.playNext, - child: ListTile( - leading: const Icon(Icons.queue_music), - title: Text(AppLocalizations.of(context)!.playNext), + PopupMenuItem( + value: SongListTileMenuItems.playNext, + child: ListTile( + leading: const Icon(Icons.queue_music), + title: Text(AppLocalizations.of(context)!.playNext), + ), ), - ), + ], PopupMenuItem( value: SongListTileMenuItems.replaceQueueWithItem, child: ListTile( diff --git a/lib/components/MusicScreen/album_item.dart b/lib/components/MusicScreen/album_item.dart index 93cd8fb62..db339f37c 100644 --- a/lib/components/MusicScreen/album_item.dart +++ b/lib/components/MusicScreen/album_item.dart @@ -98,11 +98,7 @@ class _AlbumItemState extends State { onLongPressStart: (details) async { Feedback.forLongPress(context); - if (FinampSettingsHelper.finampSettings.isOffline) { - // If offline, don't show the context menu since the only options here - // are for online. - return; - } + final isOffline = FinampSettingsHelper.finampSettings.isOffline; final jellyfinApiHelper = GetIt.instance(); @@ -115,48 +111,58 @@ class _AlbumItemState extends State { screenSize.height - details.globalPosition.dy, ), items: [ - PopupMenuItem<_AlbumListTileMenuItems>( - value: _AlbumListTileMenuItems.addToQueue, - child: ListTile( - leading: const Icon(Icons.queue_music), - title: Text(AppLocalizations.of(context)!.addToQueue), + if (_audioServiceHelper.hasQueueItems()) ...[ + PopupMenuItem<_AlbumListTileMenuItems>( + value: _AlbumListTileMenuItems.addToQueue, + child: ListTile( + leading: const Icon(Icons.queue_music), + title: Text(AppLocalizations.of(context)!.addToQueue), + ), ), - ), - PopupMenuItem<_AlbumListTileMenuItems>( - value: _AlbumListTileMenuItems.playNext, - child: ListTile( - leading: const Icon(Icons.queue_music), - title: Text(AppLocalizations.of(context)!.playNext), + PopupMenuItem<_AlbumListTileMenuItems>( + value: _AlbumListTileMenuItems.playNext, + child: ListTile( + leading: const Icon(Icons.queue_music), + title: Text(AppLocalizations.of(context)!.playNext), + ), ), - ), + ], mutableAlbum.userData!.isFavorite ? PopupMenuItem<_AlbumListTileMenuItems>( + enabled: !isOffline, value: _AlbumListTileMenuItems.removeFavourite, child: ListTile( + enabled: !isOffline, leading: const Icon(Icons.favorite_border), title: Text(AppLocalizations.of(context)!.removeFavourite), ), ) : PopupMenuItem<_AlbumListTileMenuItems>( + enabled: !isOffline, value: _AlbumListTileMenuItems.addFavourite, child: ListTile( + enabled: !isOffline, leading: const Icon(Icons.favorite), title: Text(AppLocalizations.of(context)!.addFavourite), ), ), jellyfinApiHelper.selectedMixAlbumIds.contains(mutableAlbum.id) ? PopupMenuItem<_AlbumListTileMenuItems>( + enabled: !isOffline, value: _AlbumListTileMenuItems.removeFromMixList, child: ListTile( + enabled: !isOffline, leading: const Icon(Icons.explore_off), title: Text(AppLocalizations.of(context)!.removeFromMix), ), ) : PopupMenuItem<_AlbumListTileMenuItems>( + enabled: !isOffline, value: _AlbumListTileMenuItems.addToMixList, child: ListTile( + enabled: !isOffline, leading: const Icon(Icons.explore), title: Text(AppLocalizations.of(context)!.addToMix), ), diff --git a/lib/services/audio_service_helper.dart b/lib/services/audio_service_helper.dart index 7439b55d1..925bb2111 100644 --- a/lib/services/audio_service_helper.dart +++ b/lib/services/audio_service_helper.dart @@ -64,6 +64,10 @@ class AudioServiceHelper { } } + bool hasQueueItems() { + return (_audioHandler.queue.valueOrNull?.length ?? 0) != 0; + } + @Deprecated("Use addQueueItems instead") Future addQueueItem(BaseItemDto item) async { await addQueueItems([item]);