diff --git a/MusicX.Core/Services/VkService.cs b/MusicX.Core/Services/VkService.cs index 9065c25..b5f30d1 100644 --- a/MusicX.Core/Services/VkService.cs +++ b/MusicX.Core/Services/VkService.cs @@ -1256,5 +1256,34 @@ public async Task GetStreamMixSettings(string mixId) } } + + public async Task GetAudioMyAudios() + { + try + { + var parameters = new VkParameters + { + + {"device_id", await _deviceIdStore.GetDeviceIdAsync()}, + + {"need_blocks", true}, + }; + + + var model = await apiInvoke.CallAsync("catalog.getAudioMyAudios", parameters); + + if (model.Section is null && model.Catalog?.Sections is [var firstSection, ..]) + model.Section = firstSection; + + IIdentifiable.Process(model); + return model; + }catch (Exception ex) + { + logger.Error("VK API ERROR:"); + logger.Error(ex, ex.Message); + throw; + } + + } } } diff --git a/MusicX/Controls/Blocks/TitleBlockControl.xaml.cs b/MusicX/Controls/Blocks/TitleBlockControl.xaml.cs index d262202..1f87778 100644 --- a/MusicX/Controls/Blocks/TitleBlockControl.xaml.cs +++ b/MusicX/Controls/Blocks/TitleBlockControl.xaml.cs @@ -4,6 +4,7 @@ using System.Windows; using System.Windows.Controls; using Microsoft.Extensions.DependencyInjection; +using MusicX.Core.Services; using MusicX.ViewModels; namespace MusicX.Controls.Blocks @@ -95,7 +96,25 @@ private async void MoreButton_Click(object sender, RoutedEventArgs e) var button = ViewModel.Buttons[0]; if (!string.IsNullOrEmpty(button.SectionId)) + { navigationService.OpenSection(button.SectionId); + return; + } + + if (button.Action is { Type: "open_url", Target: "internal", Url: { } url }) + { + if (url == "https://vk.com/audio?catalog=my_audios") + { + navigationService.OpenSection("my_audios"); + return; + } + + var vkService = StaticService.Container.GetRequiredService(); + + var catalog = await vkService.GetAudioCatalogAsync(url); + + navigationService.OpenSection(catalog.Catalog.DefaultSection); + } } catch (Exception ex) { diff --git a/MusicX/Helpers/NavigationServiceExtensions.cs b/MusicX/Helpers/NavigationServiceExtensions.cs index 1d02b48..175656b 100644 --- a/MusicX/Helpers/NavigationServiceExtensions.cs +++ b/MusicX/Helpers/NavigationServiceExtensions.cs @@ -88,7 +88,7 @@ public static async Task OpenLinkAsync(this NavigationService navigationService, if (link.Url == "https://vk.com/audio?catalog=my_audios") { - navigationService.OpenMenuSection("Музыка"); + navigationService.OpenSection("my_audios"); return; } diff --git a/MusicX/Services/CustomSectionsService.cs b/MusicX/Services/CustomSectionsService.cs index e809c9f..6b7e346 100644 --- a/MusicX/Services/CustomSectionsService.cs +++ b/MusicX/Services/CustomSectionsService.cs @@ -66,6 +66,7 @@ public async IAsyncEnumerable
GetSectionsAsync() }, "track_recomms_full" => await GetTrackRecommsSectionAsync(nextFrom), "track_popular_full" => await GetPopularTracksSectionAsync(nextFrom), + "my_audios" => await StaticService.Container.GetRequiredService().GetAudioMyAudios(), _ when CustomLinkRegex().IsMatch(id) => await GetAttachmentsSectionAsync(id, nextFrom), _ => null };