From d716f9a96076e15673a560445981a038ebe623d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Kro=CC=81l?= Date: Mon, 30 Sep 2024 14:49:10 +0200 Subject: [PATCH 1/5] Adding curated playlists to track collections --- ...ectionAlreadyInTrackCollectionException.cs | 5 ++++ BMM.Api/Framework/HTTP/ApiUris.cs | 1 + BMM.Api/Framework/HTTP/BadRequestThrower.cs | 2 ++ .../Contracts/ITrackCollectionClient.cs | 2 ++ .../Clients/TrackCollectionClient.cs | 16 ++++++++---- BMM.Core/Helpers/IShareLink.cs | 1 + BMM.Core/Helpers/ShareLink.cs | 5 ++++ BMM.Core/Implementations/Analytics/Event.cs | 3 +++ .../CachedTrackCollectionClientDecorator.cs | 5 ++++ ...MeasuringTrackCollectionClientDecorator.cs | 5 ++++ .../TrackCollectionManager.cs | 14 ++++++++-- .../Translation/en/Translations.designer.cs | 2 ++ BMM.Core/Translation/en/main.json | 2 ++ BMM.Core/ViewModels/AlbumViewModel.cs | 2 +- BMM.Core/ViewModels/Base/BaseViewModel.cs | 26 ++++++++++++++++--- .../TrackCollectionsAddToViewModel.cs | 4 +++ .../CuratedPlaylistViewController.cs | 20 +++++++++++++- 17 files changed, 102 insertions(+), 13 deletions(-) create mode 100644 BMM.Api/Framework/Exceptions/CollectionAlreadyInTrackCollectionException.cs diff --git a/BMM.Api/Framework/Exceptions/CollectionAlreadyInTrackCollectionException.cs b/BMM.Api/Framework/Exceptions/CollectionAlreadyInTrackCollectionException.cs new file mode 100644 index 000000000..d4fe7628a --- /dev/null +++ b/BMM.Api/Framework/Exceptions/CollectionAlreadyInTrackCollectionException.cs @@ -0,0 +1,5 @@ +namespace BMM.Api.Framework.Exceptions +{ + public class CollectionAlreadyInTrackCollectionException : BadRequestException + { } +} \ No newline at end of file diff --git a/BMM.Api/Framework/HTTP/ApiUris.cs b/BMM.Api/Framework/HTTP/ApiUris.cs index 5c45804de..9d69a5e36 100644 --- a/BMM.Api/Framework/HTTP/ApiUris.cs +++ b/BMM.Api/Framework/HTTP/ApiUris.cs @@ -32,6 +32,7 @@ public class ApiUris public static string TrackCollections = "track_collection/"; public static string TrackCollection = "track_collection/{id}"; public static string TrackCollectionAlbum = "track_collection/{id}/album/{albumId}"; + public static string TrackCollectionPlaylist = "track_collection/{id}/playlist/{playlistId}"; public static string TrackCollectionResetShare = "track_collection/{id}/reset-share"; public static string TrackCollectionUnfollow = "track_collection/{id}/unfollow"; public static string TrackCollectionTopSongs = "track_collection/top-songs"; diff --git a/BMM.Api/Framework/HTTP/BadRequestThrower.cs b/BMM.Api/Framework/HTTP/BadRequestThrower.cs index b43fd9f16..9ac4c70d5 100644 --- a/BMM.Api/Framework/HTTP/BadRequestThrower.cs +++ b/BMM.Api/Framework/HTTP/BadRequestThrower.cs @@ -30,6 +30,8 @@ public async Task ThrowExceptionForBadRequest(HttpResponseMessage response) throw new TrackNotInTrackCollectionException(); if (status.Errors.Any(e => e.StartsWith("AlbumAlreadyInTrackCollection"))) throw new AlbumAlreadyInTrackCollectionException(); + if (status.Errors.Any(e => e.StartsWith("CollectionAlreadyInTrackCollection"))) + throw new CollectionAlreadyInTrackCollectionException(); if (status.Errors.Any(e => e.StartsWith("You cannot follow your own track_collection"))) throw new FollowOwnTrackCollectionException(); } diff --git a/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs b/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs index 580a9f242..1337f2fe5 100644 --- a/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs +++ b/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs @@ -11,6 +11,8 @@ public interface ITrackCollectionClient Task AddTracksToTrackCollection(int id, IList trackIds); Task AddAlbumToTrackCollection(int id, int albumId); + + Task AddPlaylistToTrackCollection(int id, int playlistId); /// Deletes the track collection. Task Delete(int id); diff --git a/BMM.Api/Implementation/Clients/TrackCollectionClient.cs b/BMM.Api/Implementation/Clients/TrackCollectionClient.cs index 62c54eec4..14e3d39b5 100644 --- a/BMM.Api/Implementation/Clients/TrackCollectionClient.cs +++ b/BMM.Api/Implementation/Clients/TrackCollectionClient.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; -using BMM.Api.Abstraction; +using BMM.Api.Abstraction; using BMM.Api.Framework; using BMM.Api.Framework.HTTP; using BMM.Api.Implementation.Clients.Contracts; @@ -37,6 +33,16 @@ public async Task AddTracksToTrackCollection(int id, IList trackIds) return await RequestIsSuccessful(request); } + + public async Task AddPlaylistToTrackCollection(int id, int playlistId) + { + var uri = new UriTemplate(ApiUris.TrackCollectionPlaylist); + uri.SetParameter("id", id); + uri.SetParameter("playlistId", playlistId); + + var request = BuildRequest(uri, HttpMethod.Post); + await RequestIsSuccessful(request); + } public async Task Delete(int id) { diff --git a/BMM.Core/Helpers/IShareLink.cs b/BMM.Core/Helpers/IShareLink.cs index 96e946bf8..b060bc72d 100644 --- a/BMM.Core/Helpers/IShareLink.cs +++ b/BMM.Core/Helpers/IShareLink.cs @@ -9,6 +9,7 @@ public interface IShareLink Task Share(Track track); Task Share(Album album); Task Share(Contributor contributor); + Task Share(Playlist playlist); Task PerformRequestFor(string link); } } \ No newline at end of file diff --git a/BMM.Core/Helpers/ShareLink.cs b/BMM.Core/Helpers/ShareLink.cs index 37e897ceb..94cc87581 100644 --- a/BMM.Core/Helpers/ShareLink.cs +++ b/BMM.Core/Helpers/ShareLink.cs @@ -33,6 +33,11 @@ public async Task Share(Contributor contributor) await GenerateLinkAndShare($"playlist/contributor/{contributor.Id}/{contributor.Name}"); } + public async Task Share(Playlist playlist) + { + await GenerateLinkAndShare($"playlist/curated/{playlist.Id}/{playlist.Title}"); + } + public async Task PerformRequestFor(string link) { await Microsoft.Maui.ApplicationModel.DataTransfer.Share.RequestAsync(new ShareTextRequest diff --git a/BMM.Core/Implementations/Analytics/Event.cs b/BMM.Core/Implementations/Analytics/Event.cs index 14f3fa9a4..7bec7cbd9 100644 --- a/BMM.Core/Implementations/Analytics/Event.cs +++ b/BMM.Core/Implementations/Analytics/Event.cs @@ -35,5 +35,8 @@ public class Event public const string ProblemWithOfflineFileDetected = "Problem with offline file detected"; public const string NavigateToExternalLink = "Navigate to external link"; public const string BCCMediaOpenedFromPlayer = "BCC Media opened from player"; + public const string AlbumAddedToTrackCollection = "added album to track_collection"; + public const string TrackAddedToTrackCollection = "added track to track_collection"; + public const string PlaylistAddedToTrackCollection = "added playlist to track_collection"; } } \ No newline at end of file diff --git a/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs b/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs index 231905199..3200bf4ca 100644 --- a/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs +++ b/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs @@ -29,6 +29,11 @@ public Task AddAlbumToTrackCollection(int id, int albumId) return _client.AddAlbumToTrackCollection(id, albumId); } + public Task AddPlaylistToTrackCollection(int id, int playlistId) + { + return _client.AddPlaylistToTrackCollection(id, playlistId); + } + public Task Delete(int id) { return _client.Delete(id); diff --git a/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs b/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs index b38b6bd9d..c368137e9 100644 --- a/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs +++ b/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs @@ -28,6 +28,11 @@ public Task AddAlbumToTrackCollection(int id, int albumId) return _client.AddAlbumToTrackCollection(id, albumId); } + public Task AddPlaylistToTrackCollection(int id, int playlistId) + { + return _client.AddPlaylistToTrackCollection(id, playlistId); + } + public Task Delete(int id) { return _client.Delete(id); diff --git a/BMM.Core/Implementations/TrackCollections/TrackCollectionManager.cs b/BMM.Core/Implementations/TrackCollections/TrackCollectionManager.cs index 6a9555fe2..0523d64d3 100644 --- a/BMM.Core/Implementations/TrackCollections/TrackCollectionManager.cs +++ b/BMM.Core/Implementations/TrackCollections/TrackCollectionManager.cs @@ -68,7 +68,7 @@ public async Task AddToTrackCollection(TrackCollection trackCollection, int id, if (type == DocumentType.Album) { await _bmmClient.TrackCollection.AddAlbumToTrackCollection(trackCollection.Id, id); - _analytics.LogEvent("added album to track_collection", + _analytics.LogEvent(Event.AlbumAddedToTrackCollection, new Dictionary { {"AlbumId", id}, @@ -78,13 +78,23 @@ public async Task AddToTrackCollection(TrackCollection trackCollection, int id, else if (type == DocumentType.Track) { await _bmmClient.TrackCollection.AddTracksToTrackCollection(trackCollection.Id, new List {id}); - _analytics.LogEvent("added track to track_collection", + _analytics.LogEvent(Event.TrackAddedToTrackCollection, new Dictionary { {"TrackId", id}, {"Origin", origin} }); } + else if (type == DocumentType.Playlist) + { + await _bmmClient.TrackCollection.AddPlaylistToTrackCollection(trackCollection.Id, id); + _analytics.LogEvent(Event.PlaylistAddedToTrackCollection, + new Dictionary + { + {"PlaylistId", id}, + {"Origin", origin} + }); + } else { throw new UnsupportedDocumentTypeException(); diff --git a/BMM.Core/Translation/en/Translations.designer.cs b/BMM.Core/Translation/en/Translations.designer.cs index f1e3f9df8..a66caff7c 100644 --- a/BMM.Core/Translation/en/Translations.designer.cs +++ b/BMM.Core/Translation/en/Translations.designer.cs @@ -332,6 +332,7 @@ public static class Translations public const string TrackCollectionsAddToViewModel_SearchHint = nameof(TrackCollectionsAddToViewModel_SearchHint); public const string TrackCollectionsAddToViewModel_FailedToAdd = nameof(TrackCollectionsAddToViewModel_FailedToAdd); public const string TrackCollectionsAddToViewModel_AlbumFailedToAddAlreadyExists = nameof(TrackCollectionsAddToViewModel_AlbumFailedToAddAlreadyExists); + public const string TrackCollectionsAddToViewModel_CollectionAlreadyInTrackCollection = nameof(TrackCollectionsAddToViewModel_CollectionAlreadyInTrackCollection); public const string TrackCollectionsAddToViewModel_TrackAlreadyExistInTrackCollection = nameof(TrackCollectionsAddToViewModel_TrackAlreadyExistInTrackCollection); public const string TrackCollectionsAddToViewModel_FailedToAddAlbum = nameof(TrackCollectionsAddToViewModel_FailedToAddAlbum); public const string TrackCollectionsAddToViewModel_FailedToAddUnknownType = nameof(TrackCollectionsAddToViewModel_FailedToAddUnknownType); @@ -371,6 +372,7 @@ public static class Translations public const string UserDialogs_Contributor_Play = nameof(UserDialogs_Contributor_Play); public const string UserDialogs_Contributor_Share = nameof(UserDialogs_Contributor_Share); public const string UserDialogs_OfflineTrackCollection_DeletePlaylist = nameof(UserDialogs_OfflineTrackCollection_DeletePlaylist); + public const string UserDialogs_AddAllToPlaylist = nameof(UserDialogs_AddAllToPlaylist); public const string UserDialogs_Cancel = nameof(UserDialogs_Cancel); public const string Notifications_Downloading = nameof(Notifications_Downloading); public const string Notifications_ItemsDownloaded = nameof(Notifications_ItemsDownloaded); diff --git a/BMM.Core/Translation/en/main.json b/BMM.Core/Translation/en/main.json index 8ab85f798..8f4341483 100644 --- a/BMM.Core/Translation/en/main.json +++ b/BMM.Core/Translation/en/main.json @@ -415,6 +415,7 @@ "SearchHint": "Search", "FailedToAdd": "Failed to add the track to the playlist. Please try again later.", "AlbumFailedToAddAlreadyExists": "This album is already in your playlist.", + "CollectionAlreadyInTrackCollection": "Collection is already added to your playlist.", "TrackAlreadyExistInTrackCollection": "Track already exists in playlist {0}", "FailedToAddAlbum": "Failed to add the album to the playlist because it contains albums.", "FailedToAddUnknownType": "Adding a \"{0}\" to a playlist is currently not supported.", @@ -456,6 +457,7 @@ "Contributor.Play": "Play", "Contributor.Share": "Share contributor", "OfflineTrackCollection.DeletePlaylist": "Delete playlist", + "AddAllToPlaylist": "Add all tracks to playlist", "Cancel": "Cancel" }, "Notifications": { diff --git a/BMM.Core/ViewModels/AlbumViewModel.cs b/BMM.Core/ViewModels/AlbumViewModel.cs index 27bbc3c7d..e62fb5f93 100644 --- a/BMM.Core/ViewModels/AlbumViewModel.cs +++ b/BMM.Core/ViewModels/AlbumViewModel.cs @@ -67,7 +67,7 @@ public AlbumViewModel( _documentsPOFactory = documentsPOFactory; _playOrResumePlayAction.AttachDataContext(this); - AddToPlaylistCommand = new ExceptionHandlingCommand(async () => await AddAlbumToTrackCollection(Album.Id)); + AddToPlaylistCommand = new ExceptionHandlingCommand(async () => await AddToTrackCollection(Album.Id, DocumentType.Album)); ShareCommand = new ExceptionHandlingCommand(async () => await shareLink.Share(_album)); var audiobookStyler = new AudiobookPodcastInfoProvider(TrackInfoProvider); diff --git a/BMM.Core/ViewModels/Base/BaseViewModel.cs b/BMM.Core/ViewModels/Base/BaseViewModel.cs index c69f60791..ee4196baa 100644 --- a/BMM.Core/ViewModels/Base/BaseViewModel.cs +++ b/BMM.Core/ViewModels/Base/BaseViewModel.cs @@ -195,7 +195,7 @@ protected virtual async Task OptionsAction(Document item) var album = (Album)item; bmmUserDialogs.ActionSheet(new ActionSheetConfig() .SetTitle(album.Title) - .AddHandled(TextSource[Translations.UserDialogs_Album_AddToPlaylist], async () => await AddAlbumToTrackCollection(album.Id), ImageResourceNames.IconFavorites) + .AddHandled(TextSource[Translations.UserDialogs_Album_AddToPlaylist], async () => await AddToTrackCollection(album.Id, DocumentType.Album), ImageResourceNames.IconFavorites) .AddHandled(TextSource[Translations.UserDialogs_Album_Share], async () => await Mvx.IoCProvider.Resolve().Share(album), ImageResourceNames.IconShare) .SetCancel(TextSource[Translations.UserDialogs_Cancel])); break; @@ -231,6 +231,24 @@ protected virtual async Task OptionsAction(Document item) var podcastId = item.Id; await NavigationService.Navigate(podcastId); break; + + case DocumentType.Playlist: + var playlist = (Playlist)item; + + bmmUserDialogs.ActionSheet(new ActionSheetConfig() + .SetTitle(playlist.Title) + .AddHandled(TextSource[Translations.UserDialogs_AddAllToPlaylist], + async () => + await AddToTrackCollection( + playlist.Id, + DocumentType.Playlist), + ImageResourceNames.IconFavorites) + .AddHandled(TextSource[Translations.TrackCollectionViewModel_SharePlaylist], + async () => await Mvx.IoCProvider.Resolve().Share(playlist), + ImageResourceNames.IconShare) + .SetCancel(TextSource[Translations.UserDialogs_Cancel])); + + break; default: throw new ArgumentOutOfRangeException(); @@ -437,12 +455,12 @@ protected virtual async Task DeleteTrackCollection(TrackCollection item) return false; } - protected Task AddAlbumToTrackCollection(int albumId) + protected Task AddToTrackCollection(int documentId, DocumentType documentType) { return NavigationService.Navigate(new TrackCollectionsAddToViewModel.Parameter { - DocumentId = albumId, - DocumentType = DocumentType.Album, + DocumentId = documentId, + DocumentType = documentType, OriginViewModel = PlaybackOriginString() }); } diff --git a/BMM.Core/ViewModels/TrackCollectionsAddToViewModel.cs b/BMM.Core/ViewModels/TrackCollectionsAddToViewModel.cs index 33c5d5bda..20b3e38b5 100644 --- a/BMM.Core/ViewModels/TrackCollectionsAddToViewModel.cs +++ b/BMM.Core/ViewModels/TrackCollectionsAddToViewModel.cs @@ -75,6 +75,10 @@ protected override async Task DocumentAction(IDocumentPO item, IList list { await _userDialogs.AlertAsync(TextSource.GetText(Translations.TrackCollectionsAddToViewModel_FailedToAddUnknownType, _documentType.ToString())); } + catch (CollectionAlreadyInTrackCollectionException) + { + await _userDialogs.AlertAsync(TextSource[Translations.TrackCollectionsAddToViewModel_CollectionAlreadyInTrackCollection]); + } catch (AlbumAlreadyInTrackCollectionException) { await _userDialogs.AlertAsync(TextSource.GetText(Translations.TrackCollectionsAddToViewModel_AlbumFailedToAddAlreadyExists, targetTrackCollection.TrackCollection.Name)); diff --git a/BMM.UI.iOS/Application/ViewController/CuratedPlaylistViewController.cs b/BMM.UI.iOS/Application/ViewController/CuratedPlaylistViewController.cs index 0eb0a13cd..f40d62905 100644 --- a/BMM.UI.iOS/Application/ViewController/CuratedPlaylistViewController.cs +++ b/BMM.UI.iOS/Application/ViewController/CuratedPlaylistViewController.cs @@ -14,6 +14,8 @@ namespace BMM.UI.iOS { public partial class CuratedPlaylistViewController : BaseViewController { + private UIBarButtonItem _sidebarButton; + public CuratedPlaylistViewController() : base(nameof(CuratedPlaylistViewController)) { } @@ -24,6 +26,8 @@ public override void ViewDidLoad() { base.ViewDidLoad(); + AddNavigationBarItemForOptions(); + var refreshControl = new MvxUIRefreshControl {TintColor = AppColors.RefreshControlTintColor}; CuratedPlaylistTable.RefreshControl = refreshControl; @@ -33,6 +37,11 @@ public override void ViewDidLoad() DownloadButton.NormalStateImage = UIImage.FromBundle("IconDownload"); var set = this.CreateBindingSet(); + + set.Bind(_sidebarButton) + .To(vm => vm.OptionCommand) + .CommandParameter(ViewModel!.CuratedPlaylist); + set.Bind(this).For(c => c.Title).To(vm => vm.CuratedPlaylist.Title); set.Bind(source).To(vm => vm.Documents); set.Bind(source).For(s => s.SelectionChangedCommand).To(s => s.DocumentSelectedCommand); @@ -74,8 +83,17 @@ private void SetThemes() public override void ViewDidLayoutSubviews() { base.ViewDidLayoutSubviews(); - CuratedPlaylistTable?.ResizeHeaderView(); } + + private void AddNavigationBarItemForOptions() + { + _sidebarButton = new UIBarButtonItem( + new UIImage("icon_options"), + UIBarButtonItemStyle.Plain, + default); + + NavigationItem.SetRightBarButtonItem(_sidebarButton, true); + } } } \ No newline at end of file From c4493e8258a8a98091e9a74136369fb1f8371209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Kro=CC=81l?= Date: Mon, 30 Sep 2024 15:35:10 +0200 Subject: [PATCH 2/5] Adding private playlists to track collections --- BMM.Api/Framework/HTTP/ApiUris.cs | 1 + .../Contracts/ITrackCollectionClient.cs | 2 ++ .../Clients/TrackCollectionClient.cs | 10 ++++++++++ .../Extensions/ActionSheetConfigExtensions.cs | 20 +++++++++++++++++++ BMM.Core/Implementations/Analytics/Event.cs | 1 + .../CachedTrackCollectionClientDecorator.cs | 5 +++++ ...MeasuringTrackCollectionClientDecorator.cs | 9 ++++++--- .../TrackCollectionManager.cs | 10 ++++++++++ BMM.Core/ViewModels/Base/BaseViewModel.cs | 16 +++++++++------ 9 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 BMM.Core/Extensions/ActionSheetConfigExtensions.cs diff --git a/BMM.Api/Framework/HTTP/ApiUris.cs b/BMM.Api/Framework/HTTP/ApiUris.cs index 9d69a5e36..a5e781b03 100644 --- a/BMM.Api/Framework/HTTP/ApiUris.cs +++ b/BMM.Api/Framework/HTTP/ApiUris.cs @@ -33,6 +33,7 @@ public class ApiUris public static string TrackCollection = "track_collection/{id}"; public static string TrackCollectionAlbum = "track_collection/{id}/album/{albumId}"; public static string TrackCollectionPlaylist = "track_collection/{id}/playlist/{playlistId}"; + public static string TrackCollectionTrackCollection = "track_collection/{id}/track_collection/{playlistId}"; public static string TrackCollectionResetShare = "track_collection/{id}/reset-share"; public static string TrackCollectionUnfollow = "track_collection/{id}/unfollow"; public static string TrackCollectionTopSongs = "track_collection/top-songs"; diff --git a/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs b/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs index 1337f2fe5..2efe43d6e 100644 --- a/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs +++ b/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs @@ -13,6 +13,8 @@ public interface ITrackCollectionClient Task AddAlbumToTrackCollection(int id, int albumId); Task AddPlaylistToTrackCollection(int id, int playlistId); + + Task AddTrackCollectionToTrackCollection(int id, int trackCollectionId); /// Deletes the track collection. Task Delete(int id); diff --git a/BMM.Api/Implementation/Clients/TrackCollectionClient.cs b/BMM.Api/Implementation/Clients/TrackCollectionClient.cs index 14e3d39b5..161e3c770 100644 --- a/BMM.Api/Implementation/Clients/TrackCollectionClient.cs +++ b/BMM.Api/Implementation/Clients/TrackCollectionClient.cs @@ -44,6 +44,16 @@ public async Task AddPlaylistToTrackCollection(int id, int playlistId) await RequestIsSuccessful(request); } + public async Task AddTrackCollectionToTrackCollection(int id, int trackCollectionId) + { + var uri = new UriTemplate(ApiUris.TrackCollectionTrackCollection); + uri.SetParameter("id", id); + uri.SetParameter("playlistId", trackCollectionId); + + var request = BuildRequest(uri, HttpMethod.Post); + await RequestIsSuccessful(request); + } + public async Task Delete(int id) { var uri = new UriTemplate(ApiUris.TrackCollection); diff --git a/BMM.Core/Extensions/ActionSheetConfigExtensions.cs b/BMM.Core/Extensions/ActionSheetConfigExtensions.cs new file mode 100644 index 000000000..f82759759 --- /dev/null +++ b/BMM.Core/Extensions/ActionSheetConfigExtensions.cs @@ -0,0 +1,20 @@ +using Acr.UserDialogs; +using BMM.Core.Constants; +using BMM.Core.Helpers; +using BMM.Core.Implementations.Localization; +using BMM.Core.Implementations.Localization.Interfaces; +using BMM.Core.Translation; + +namespace BMM.Core.Extensions; + +public static class ActionSheetConfigExtensions +{ + private static IBMMLanguageBinder TextSource => BMMLanguageBinderLocator.TextSource; + + public static ActionSheetConfig AddOptionForAddToTrackCollection(this ActionSheetConfig actionSheetConfig, Func action) + { + return actionSheetConfig.AddHandled(TextSource[Translations.UserDialogs_AddAllToPlaylist], + async () => await action(), + ImageResourceNames.IconFavorites); + } +} \ No newline at end of file diff --git a/BMM.Core/Implementations/Analytics/Event.cs b/BMM.Core/Implementations/Analytics/Event.cs index 7bec7cbd9..c69bc8b59 100644 --- a/BMM.Core/Implementations/Analytics/Event.cs +++ b/BMM.Core/Implementations/Analytics/Event.cs @@ -38,5 +38,6 @@ public class Event public const string AlbumAddedToTrackCollection = "added album to track_collection"; public const string TrackAddedToTrackCollection = "added track to track_collection"; public const string PlaylistAddedToTrackCollection = "added playlist to track_collection"; + public const string TrackCollectionAddedToTrackCollection = "added track collection to track_collection"; } } \ No newline at end of file diff --git a/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs b/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs index 3200bf4ca..38640ce0b 100644 --- a/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs +++ b/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs @@ -34,6 +34,11 @@ public Task AddPlaylistToTrackCollection(int id, int playlistId) return _client.AddPlaylistToTrackCollection(id, playlistId); } + public Task AddTrackCollectionToTrackCollection(int id, int trackCollectionId) + { + return _client.AddTrackCollectionToTrackCollection(id, trackCollectionId); + } + public Task Delete(int id) { return _client.Delete(id); diff --git a/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs b/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs index c368137e9..a4694124d 100644 --- a/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs +++ b/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using BMM.Api.Abstraction; +using BMM.Api.Abstraction; using BMM.Api.Implementation.Clients.Contracts; using BMM.Api.Implementation.Models; using BMM.Core.Implementations.Analytics; @@ -33,6 +31,11 @@ public Task AddPlaylistToTrackCollection(int id, int playlistId) return _client.AddPlaylistToTrackCollection(id, playlistId); } + public Task AddTrackCollectionToTrackCollection(int id, int trackCollectionId) + { + return _client.AddTrackCollectionToTrackCollection(id, trackCollectionId); + } + public Task Delete(int id) { return _client.Delete(id); diff --git a/BMM.Core/Implementations/TrackCollections/TrackCollectionManager.cs b/BMM.Core/Implementations/TrackCollections/TrackCollectionManager.cs index 0523d64d3..cb97304f3 100644 --- a/BMM.Core/Implementations/TrackCollections/TrackCollectionManager.cs +++ b/BMM.Core/Implementations/TrackCollections/TrackCollectionManager.cs @@ -95,6 +95,16 @@ public async Task AddToTrackCollection(TrackCollection trackCollection, int id, {"Origin", origin} }); } + else if (type == DocumentType.TrackCollection) + { + await _bmmClient.TrackCollection.AddTrackCollectionToTrackCollection(trackCollection.Id, id); + _analytics.LogEvent(Event.TrackCollectionAddedToTrackCollection, + new Dictionary + { + {"TrackCollectionId", id}, + {"Origin", origin} + }); + } else { throw new UnsupportedDocumentTypeException(); diff --git a/BMM.Core/ViewModels/Base/BaseViewModel.cs b/BMM.Core/ViewModels/Base/BaseViewModel.cs index ee4196baa..b21006835 100644 --- a/BMM.Core/ViewModels/Base/BaseViewModel.cs +++ b/BMM.Core/ViewModels/Base/BaseViewModel.cs @@ -9,6 +9,7 @@ using BMM.Api.Framework; using BMM.Api.Implementation.Models; using BMM.Core.Constants; +using BMM.Core.Extensions; using BMM.Core.GuardedActions.TrackOptions.Interfaces; using BMM.Core.GuardedActions.TrackOptions.Parameters; using BMM.Core.Helpers; @@ -237,12 +238,9 @@ protected virtual async Task OptionsAction(Document item) bmmUserDialogs.ActionSheet(new ActionSheetConfig() .SetTitle(playlist.Title) - .AddHandled(TextSource[Translations.UserDialogs_AddAllToPlaylist], - async () => - await AddToTrackCollection( - playlist.Id, - DocumentType.Playlist), - ImageResourceNames.IconFavorites) + .AddOptionForAddToTrackCollection(async () => await AddToTrackCollection( + playlist.Id, + DocumentType.Playlist)) .AddHandled(TextSource[Translations.TrackCollectionViewModel_SharePlaylist], async () => await Mvx.IoCProvider.Resolve().Share(playlist), ImageResourceNames.IconShare) @@ -268,6 +266,9 @@ private void ShowActionSheetIfSharedTrackCollection( { userDialogs.ActionSheet(new ActionSheetConfig() .SetTitle(trackCollection.Name) + .AddOptionForAddToTrackCollection(async () => await AddToTrackCollection( + trackCollection.Id, + DocumentType.TrackCollection)) .AddHandled( TextSource[Translations.TrackCollectionViewModel_RemovePlaylist], async () => await RemoveSharedPlaylist(trackCollection.Id), @@ -283,6 +284,9 @@ private void ShowActionSheetIfPrivateTrackCollection( { userDialogs.ActionSheet(new ActionSheetConfig() .SetTitle(trackCollection.Name) + .AddOptionForAddToTrackCollection(async () => await AddToTrackCollection( + trackCollection.Id, + DocumentType.TrackCollection)) .AddHandled(TextSource[Translations.TrackCollectionViewModel_SharePlaylist], async () => { From 3296e721ee1d696e42ae27fd047a49c6b9a9e8c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Kro=CC=81l?= Date: Mon, 30 Sep 2024 16:50:39 +0200 Subject: [PATCH 3/5] Adjustments for Android menu --- BMM.Core/ViewModels/Base/BaseViewModel.cs | 7 +--- .../ViewModels/CuratedPlaylistViewModel.cs | 32 ++++++++++++------- .../ViewModels/TrackCollectionViewModel.cs | 3 ++ .../Fragments/CuratedPlaylistFragment.cs | 31 ++++++++++++++++++ .../Fragments/TrackCollectionFragment.cs | 14 +++++--- BMM.UI.Android/BMM.UI.Droid.csproj | 4 +++ .../Resources/menu/curated_playlist.xml | 9 ++++++ .../Resources/menu/trackcollection.xml | 3 ++ .../Resources/menu/trackcollection_shared.xml | 3 ++ 9 files changed, 85 insertions(+), 21 deletions(-) create mode 100644 BMM.UI.Android/Resources/menu/curated_playlist.xml diff --git a/BMM.Core/ViewModels/Base/BaseViewModel.cs b/BMM.Core/ViewModels/Base/BaseViewModel.cs index b21006835..2e77d6257 100644 --- a/BMM.Core/ViewModels/Base/BaseViewModel.cs +++ b/BMM.Core/ViewModels/Base/BaseViewModel.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Acr.UserDialogs; +using Acr.UserDialogs; using BMM.Api; using BMM.Api.Abstraction; using BMM.Api.Framework; diff --git a/BMM.Core/ViewModels/CuratedPlaylistViewModel.cs b/BMM.Core/ViewModels/CuratedPlaylistViewModel.cs index 7f72cab9a..f6e0072c1 100644 --- a/BMM.Core/ViewModels/CuratedPlaylistViewModel.cs +++ b/BMM.Core/ViewModels/CuratedPlaylistViewModel.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using BMM.Api.Abstraction; +using BMM.Api.Abstraction; using BMM.Api.Framework; using BMM.Api.Implementation.Models; +using BMM.Core.Helpers; using BMM.Core.Implementations.Caching; using BMM.Core.Implementations.Connection; using BMM.Core.Implementations.DocumentFilters; @@ -12,14 +10,11 @@ using BMM.Core.Implementations.FileStorage; using BMM.Core.Implementations.PlaylistPersistence; using BMM.Core.Implementations.TrackInformation.Strategies; -using BMM.Core.Models.POs.Base; using BMM.Core.Models.POs.Base.Interfaces; using BMM.Core.Models.POs.Tracks; -using BMM.Core.Translation; using BMM.Core.ViewModels.Base; -using BMM.Core.ViewModels.Interfaces; -using MvvmCross; using MvvmCross.Base; +using MvvmCross.Commands; using MvvmCross.ViewModels; namespace BMM.Core.ViewModels @@ -28,6 +23,8 @@ public class CuratedPlaylistViewModel : DownloadViewModel, IMvxViewModel shareLink.Share(CuratedPlaylist)); + AddToTrackCollectionCommand = new ExceptionHandlingCommand(() => AddToTrackCollection(CuratedPlaylist.Id, DocumentType.Playlist)); } + + public IMvxAsyncCommand ShareCommand { get; } + + public IMvxAsyncCommand AddToTrackCollectionCommand { get; } public void Prepare(Playlist curatedPlaylist) { CuratedPlaylist = curatedPlaylist; - Mvx.IoCProvider.Resolve() - .ExecuteOnMainThreadAsync(async () => { IsOfflineAvailable = await Mvx.IoCProvider.Resolve().IsOfflineAvailable(curatedPlaylist.Id); }); + _mainThreadAsyncDispatcher.ExecuteOnMainThreadAsync(async () => + { + IsOfflineAvailable = await _offlinePlaylistStorage.IsOfflineAvailable(curatedPlaylist.Id); + }); } public override async Task> LoadItems(CachePolicy policy = CachePolicy.UseCacheAndRefreshOutdated) diff --git a/BMM.Core/ViewModels/TrackCollectionViewModel.cs b/BMM.Core/ViewModels/TrackCollectionViewModel.cs index 60004e6dd..76aff1343 100644 --- a/BMM.Core/ViewModels/TrackCollectionViewModel.cs +++ b/BMM.Core/ViewModels/TrackCollectionViewModel.cs @@ -30,6 +30,8 @@ public class TrackCollectionViewModel : MyTracksViewModel public IMvxAsyncCommand ShareCommand { get; } public IMvxAsyncCommand RemoveCommand { get; } + + public IMvxAsyncCommand AddToTrackCollectionCommand { get; } public bool IsConnectionOnline => Connection.GetStatus() == ConnectionStatus.Online; @@ -66,6 +68,7 @@ ITrackPOFactory trackPOFactory ShareCommand = new ExceptionHandlingCommand(() => ShareTrackCollection(MyCollection.Id)); RemoveCommand = new ExceptionHandlingCommand(() => RemoveSharedPlaylist(MyCollection.Id)); + AddToTrackCollectionCommand = new ExceptionHandlingCommand(() => AddToTrackCollection(MyCollection.Id, DocumentType.TrackCollection)); } public bool UseLikeIcon diff --git a/BMM.UI.Android/Application/Fragments/CuratedPlaylistFragment.cs b/BMM.UI.Android/Application/Fragments/CuratedPlaylistFragment.cs index 82e2d4911..438512c04 100644 --- a/BMM.UI.Android/Application/Fragments/CuratedPlaylistFragment.cs +++ b/BMM.UI.Android/Application/Fragments/CuratedPlaylistFragment.cs @@ -6,6 +6,7 @@ using AndroidX.Core.Content; using AndroidX.RecyclerView.Widget; using BMM.Core.Implementations.Exceptions; +using BMM.Core.Translation; using BMM.Core.ViewModels; using BMM.UI.Droid.Application.Adapters; using BMM.UI.Droid.Application.Helpers; @@ -30,6 +31,36 @@ protected override MvxRecyclerAdapter CreateAdapter() return new HeaderRecyclerAdapter((IMvxAndroidBindingContext)BindingContext); } + public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater) + { + base.OnCreateOptionsMenu(menu, inflater); + CreateMenu(menu, inflater); + } + + private void CreateMenu(IMenu menu, MenuInflater inflater) + { + inflater.Inflate(Resource.Menu.curated_playlist, menu); + menu.GetItem(0).SetTitle(ViewModel.TextSource[Translations.UserDialogs_AddAllToPlaylist]); + menu.GetItem(1).SetTitle(ViewModel.TextSource[Translations.TrackCollectionViewModel_SharePlaylist]); + } + + public override bool OnOptionsItemSelected(IMenuItem item) + { + switch (item.ItemId) + { + case Resource.Id.menu_add_to_trackcollection: + ViewModel.AddToTrackCollectionCommand.Execute(); + return true; + + case Resource.Id.menu_share: + ViewModel.ShareCommand.Execute(); + return true; + + default: + return base.OnOptionsItemSelected(item); + } + } + public override void OnDestroy() { ViewModel.PropertyChanged -= OnViewModelPropertyChanged; diff --git a/BMM.UI.Android/Application/Fragments/TrackCollectionFragment.cs b/BMM.UI.Android/Application/Fragments/TrackCollectionFragment.cs index 75b49c02a..3c50c44ff 100644 --- a/BMM.UI.Android/Application/Fragments/TrackCollectionFragment.cs +++ b/BMM.UI.Android/Application/Fragments/TrackCollectionFragment.cs @@ -60,15 +60,17 @@ public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater) private void CreateMenuIfPrivate(IMenu menu, MenuInflater inflater) { inflater.Inflate(Resource.Menu.trackcollection, menu); - menu.GetItem(0).SetTitle(ViewModel.TextSource[Translations.TrackCollectionViewModel_SharePlaylist]); - menu.GetItem(1).SetTitle(ViewModel.TextSource[Translations.TrackCollectionViewModel_DeletePlaylist]); - menu.GetItem(2).SetTitle(ViewModel.TextSource[Translations.TrackCollectionViewModel_EditPlaylist]); + menu.GetItem(0).SetTitle(ViewModel.TextSource[Translations.UserDialogs_AddAllToPlaylist]); + menu.GetItem(1).SetTitle(ViewModel.TextSource[Translations.TrackCollectionViewModel_SharePlaylist]); + menu.GetItem(2).SetTitle(ViewModel.TextSource[Translations.TrackCollectionViewModel_DeletePlaylist]); + menu.GetItem(3).SetTitle(ViewModel.TextSource[Translations.TrackCollectionViewModel_EditPlaylist]); } private void CreateMenuIfShared(IMenu menu, MenuInflater inflater) { inflater.Inflate(Resource.Menu.trackcollection_shared, menu); - menu.GetItem(0).SetTitle(ViewModel.TextSource[Translations.TrackCollectionViewModel_RemovePlaylist]); + menu.GetItem(0).SetTitle(ViewModel.TextSource[Translations.UserDialogs_AddAllToPlaylist]); + menu.GetItem(1).SetTitle(ViewModel.TextSource[Translations.TrackCollectionViewModel_RemovePlaylist]); } public override bool OnOptionsItemSelected(IMenuItem item) @@ -90,6 +92,10 @@ public override bool OnOptionsItemSelected(IMenuItem item) case Resource.Id.menu_remove: ViewModel.RemoveCommand.Execute(); return true; + + case Resource.Id.menu_add_to_trackcollection: + ViewModel.AddToTrackCollectionCommand.Execute(); + return true; default: return base.OnOptionsItemSelected(item); diff --git a/BMM.UI.Android/BMM.UI.Droid.csproj b/BMM.UI.Android/BMM.UI.Droid.csproj index 298cfd34f..37497d717 100644 --- a/BMM.UI.Android/BMM.UI.Droid.csproj +++ b/BMM.UI.Android/BMM.UI.Droid.csproj @@ -1078,6 +1078,10 @@ Designer MSBuild:UpdateGeneratedFiles + + Designer + MSBuild:UpdateGeneratedFiles + diff --git a/BMM.UI.Android/Resources/menu/curated_playlist.xml b/BMM.UI.Android/Resources/menu/curated_playlist.xml new file mode 100644 index 000000000..8e20deb7f --- /dev/null +++ b/BMM.UI.Android/Resources/menu/curated_playlist.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/BMM.UI.Android/Resources/menu/trackcollection.xml b/BMM.UI.Android/Resources/menu/trackcollection.xml index aa9ac5433..75025d8c2 100644 --- a/BMM.UI.Android/Resources/menu/trackcollection.xml +++ b/BMM.UI.Android/Resources/menu/trackcollection.xml @@ -1,5 +1,8 @@  + diff --git a/BMM.UI.Android/Resources/menu/trackcollection_shared.xml b/BMM.UI.Android/Resources/menu/trackcollection_shared.xml index 7e4971878..5df62199a 100644 --- a/BMM.UI.Android/Resources/menu/trackcollection_shared.xml +++ b/BMM.UI.Android/Resources/menu/trackcollection_shared.xml @@ -1,5 +1,8 @@ + From a8878f9ad380d521480b5fbbb0d61575aff9c4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Kro=CC=81l?= Date: Tue, 1 Oct 2024 15:51:53 +0200 Subject: [PATCH 4/5] Install specific version of MAUI Workload as temporary fix --- azure-pipelines-ios.yaml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/azure-pipelines-ios.yaml b/azure-pipelines-ios.yaml index df1d791f6..305893c28 100644 --- a/azure-pipelines-ios.yaml +++ b/azure-pipelines-ios.yaml @@ -20,11 +20,11 @@ variables: steps: - bash: | - dotnet workload install ios + dotnet workload install ios --version 8.0.402 displayName: 'Install iOS workload' - bash: | - dotnet workload install maui-ios + dotnet workload install maui-ios --version 8.0.402 displayName: 'Install MAUI iOS workload' - task: DotNetCoreCLI@2 @@ -60,13 +60,6 @@ steps: actionOnMissing: fail keepToken: true - - bash: | - /bin/bash -c "sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 6_12_7" - xcodeRoot=/Applications/Xcode_12.4.app - /bin/bash -c "echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'${xcodeRoot};sudo xcode-select --switch ${xcodeRoot}/Contents/Developer" - displayName: 'Force SDK and Xcode version' - enabled: false - - bash: | URL="https://bmm-api.brunstad.org/AppVersion/iOSVersionCode" VERSIONCODE=$(curl -k --user $(bmmApiCredentials) $URL) From ed2c8206d2375a8c6a932faa995df6e72953b96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Kro=CC=81l?= Date: Wed, 2 Oct 2024 16:03:30 +0200 Subject: [PATCH 5/5] Renaming Id to TargetId --- BMM.Api/Framework/HTTP/ApiUris.cs | 8 ++++---- .../Clients/Contracts/ITrackCollectionClient.cs | 8 ++++---- .../Clients/TrackCollectionClient.cs | 16 ++++++++-------- .../CachedTrackCollectionClientDecorator.cs | 16 ++++++++-------- .../MeasuringTrackCollectionClientDecorator.cs | 16 ++++++++-------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/BMM.Api/Framework/HTTP/ApiUris.cs b/BMM.Api/Framework/HTTP/ApiUris.cs index a5e781b03..309df41e8 100644 --- a/BMM.Api/Framework/HTTP/ApiUris.cs +++ b/BMM.Api/Framework/HTTP/ApiUris.cs @@ -30,10 +30,10 @@ public class ApiUris public static string TrackTranscriptions = "track/{id}/transcription"; public static string TrackCover = "track/{id}/cover"; public static string TrackCollections = "track_collection/"; - public static string TrackCollection = "track_collection/{id}"; - public static string TrackCollectionAlbum = "track_collection/{id}/album/{albumId}"; - public static string TrackCollectionPlaylist = "track_collection/{id}/playlist/{playlistId}"; - public static string TrackCollectionTrackCollection = "track_collection/{id}/track_collection/{playlistId}"; + public static string TrackCollection = "track_collection/{targetId}"; + public static string TrackCollectionAlbum = "track_collection/{targetId}/album/{albumId}"; + public static string TrackCollectionPlaylist = "track_collection/{targetId}/playlist/{playlistId}"; + public static string TrackCollectionTrackCollection = "track_collection/{targetId}/track_collection/{playlistId}"; public static string TrackCollectionResetShare = "track_collection/{id}/reset-share"; public static string TrackCollectionUnfollow = "track_collection/{id}/unfollow"; public static string TrackCollectionTopSongs = "track_collection/top-songs"; diff --git a/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs b/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs index 2efe43d6e..aaa39a628 100644 --- a/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs +++ b/BMM.Api/Implementation/Clients/Contracts/ITrackCollectionClient.cs @@ -8,13 +8,13 @@ namespace BMM.Api.Implementation.Clients.Contracts public interface ITrackCollectionClient { /// Adds the tracks with the specified ids to the track collection. - Task AddTracksToTrackCollection(int id, IList trackIds); + Task AddTracksToTrackCollection(int targetId, IList trackIds); - Task AddAlbumToTrackCollection(int id, int albumId); + Task AddAlbumToTrackCollection(int targetId, int albumId); - Task AddPlaylistToTrackCollection(int id, int playlistId); + Task AddPlaylistToTrackCollection(int targetId, int playlistId); - Task AddTrackCollectionToTrackCollection(int id, int trackCollectionId); + Task AddTrackCollectionToTrackCollection(int targetId, int trackCollectionId); /// Deletes the track collection. Task Delete(int id); diff --git a/BMM.Api/Implementation/Clients/TrackCollectionClient.cs b/BMM.Api/Implementation/Clients/TrackCollectionClient.cs index 161e3c770..c4d1cc52d 100644 --- a/BMM.Api/Implementation/Clients/TrackCollectionClient.cs +++ b/BMM.Api/Implementation/Clients/TrackCollectionClient.cs @@ -13,20 +13,20 @@ public TrackCollectionClient(IRequestHandler handler, ApiBaseUri baseUri, ILogge : base(handler, baseUri, logger) { } - public async Task AddAlbumToTrackCollection(int id, int albumId) + public async Task AddAlbumToTrackCollection(int targetId, int albumId) { var uri = new UriTemplate(ApiUris.TrackCollectionAlbum); - uri.SetParameter("id", id); + uri.SetParameter("targetId", targetId); uri.SetParameter("albumId", albumId); var request = BuildRequest(uri, HttpMethod.Post); await RequestIsSuccessful(request); } - public async Task AddTracksToTrackCollection(int id, IList trackIds) + public async Task AddTracksToTrackCollection(int targetId, IList trackIds) { var uri = new UriTemplate(ApiUris.TrackCollection); - uri.SetParameter("id", id); + uri.SetParameter("targetId", targetId); var request = BuildRequest(uri, HttpMethod.Post); SetLinkHeader(trackIds, request); @@ -34,20 +34,20 @@ public async Task AddTracksToTrackCollection(int id, IList trackIds) return await RequestIsSuccessful(request); } - public async Task AddPlaylistToTrackCollection(int id, int playlistId) + public async Task AddPlaylistToTrackCollection(int targetId, int playlistId) { var uri = new UriTemplate(ApiUris.TrackCollectionPlaylist); - uri.SetParameter("id", id); + uri.SetParameter("targetId", targetId); uri.SetParameter("playlistId", playlistId); var request = BuildRequest(uri, HttpMethod.Post); await RequestIsSuccessful(request); } - public async Task AddTrackCollectionToTrackCollection(int id, int trackCollectionId) + public async Task AddTrackCollectionToTrackCollection(int targetId, int trackCollectionId) { var uri = new UriTemplate(ApiUris.TrackCollectionTrackCollection); - uri.SetParameter("id", id); + uri.SetParameter("targetId", targetId); uri.SetParameter("playlistId", trackCollectionId); var request = BuildRequest(uri, HttpMethod.Post); diff --git a/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs b/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs index 38640ce0b..aa27ac226 100644 --- a/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs +++ b/BMM.Core/Implementations/ApiClients/CachedTrackCollectionClientDecorator.cs @@ -19,24 +19,24 @@ public CachedTrackCollectionClientDecorator(ITrackCollectionClient client, IClie _clientCache = clientCache; } - public Task AddTracksToTrackCollection(int id, IList trackIds) + public Task AddTracksToTrackCollection(int targetId, IList trackIds) { - return _client.AddTracksToTrackCollection(id, trackIds); + return _client.AddTracksToTrackCollection(targetId, trackIds); } - public Task AddAlbumToTrackCollection(int id, int albumId) + public Task AddAlbumToTrackCollection(int targetId, int albumId) { - return _client.AddAlbumToTrackCollection(id, albumId); + return _client.AddAlbumToTrackCollection(targetId, albumId); } - public Task AddPlaylistToTrackCollection(int id, int playlistId) + public Task AddPlaylistToTrackCollection(int targetId, int playlistId) { - return _client.AddPlaylistToTrackCollection(id, playlistId); + return _client.AddPlaylistToTrackCollection(targetId, playlistId); } - public Task AddTrackCollectionToTrackCollection(int id, int trackCollectionId) + public Task AddTrackCollectionToTrackCollection(int targetId, int trackCollectionId) { - return _client.AddTrackCollectionToTrackCollection(id, trackCollectionId); + return _client.AddTrackCollectionToTrackCollection(targetId, trackCollectionId); } public Task Delete(int id) diff --git a/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs b/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs index a4694124d..e1d245993 100644 --- a/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs +++ b/BMM.Core/Implementations/ApiClients/MeasuringTrackCollectionClientDecorator.cs @@ -16,24 +16,24 @@ public MeasuringTrackCollectionClientDecorator(ITrackCollectionClient client, IC _stopwatchManager = stopwatchManager; } - public Task AddTracksToTrackCollection(int id, IList trackIds) + public Task AddTracksToTrackCollection(int targetId, IList trackIds) { - return _client.AddTracksToTrackCollection(id, trackIds); + return _client.AddTracksToTrackCollection(targetId, trackIds); } - public Task AddAlbumToTrackCollection(int id, int albumId) + public Task AddAlbumToTrackCollection(int targetId, int albumId) { - return _client.AddAlbumToTrackCollection(id, albumId); + return _client.AddAlbumToTrackCollection(targetId, albumId); } - public Task AddPlaylistToTrackCollection(int id, int playlistId) + public Task AddPlaylistToTrackCollection(int targetId, int playlistId) { - return _client.AddPlaylistToTrackCollection(id, playlistId); + return _client.AddPlaylistToTrackCollection(targetId, playlistId); } - public Task AddTrackCollectionToTrackCollection(int id, int trackCollectionId) + public Task AddTrackCollectionToTrackCollection(int targetId, int trackCollectionId) { - return _client.AddTrackCollectionToTrackCollection(id, trackCollectionId); + return _client.AddTrackCollectionToTrackCollection(targetId, trackCollectionId); } public Task Delete(int id)