Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Переделать код очереди #413

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 95 additions & 47 deletions MusicX.Core/Models/Block.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using MusicX.Shared.ListenTogether.Radio;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using MusicX.Core.Helpers;

namespace MusicX.Core.Models
Expand All @@ -21,16 +18,16 @@ public class Block : IIdentifiable
public Layout Layout { get; set; }

[JsonProperty("catalog_banner_ids")]
public List<int> CatalogBannerIds { get; set; } = new List<int>();
public List<int> CatalogBannerIds { get; set; } = [];

[JsonProperty("links_ids")]
public List<string> LinksIds { get; set; } = new List<string>();
public List<string> LinksIds { get; set; } = [];

[JsonProperty("buttons")]
public List<Button> Buttons { get; set; }
public List<Button> Buttons { get; set; } = [];

[JsonProperty("actions")]
public List<Button> Actions { get; set; } = new List<Button> { };
public List<Button> Actions { get; set; } = [];

[JsonProperty("next_from")]
public string NextFrom { get; set; }
Expand All @@ -39,81 +36,132 @@ public class Block : IIdentifiable
public string Url { get; set; }

[JsonProperty("listen_events")]
public List<string> ListenEvents { get; set; }
public List<string> ListenEvents { get; set; } = [];

[JsonProperty("playlists_ids")]
public List<string> PlaylistsIds { get; set; } = new List<string>();
public List<string> PlaylistsIds { get; set; } = [];

[JsonProperty("suggestions_ids")]
public List<string> SuggestionsIds { get; set; } = new List<string>();
public List<string> SuggestionsIds { get; set; } = [];

[JsonProperty("artists_ids")]
public List<string> ArtistsIds { get; set; } = new List<string>();
public List<string> ArtistsIds { get; set; } = [];

[JsonProperty("badge")]
public Badge Badge { get; set; }

[JsonProperty("audios_ids")]
public List<string> AudiosIds { get; set; } = new List<string>();
public List<string> AudiosIds { get; set; } = [];

[JsonProperty("curators_ids")]
public List<long> CuratorsIds { get; set; } = new List<long>();
public List<long> CuratorsIds { get; set; } = [];

[JsonProperty("group_ids")]
public List<long> GroupIds { get; set; } = new List<long>();
public List<long> GroupIds { get; set; } = [];

[JsonProperty("text_ids")]
public List<string> TextIds { get; set; } = new List<string>();
public List<string> TextIds { get; set; } = [];

[JsonProperty("podcast_episodes_ids")]
public List<string> PodcastEpisodesIds { get; set; } = new List<string>();
public List<string> PodcastEpisodesIds { get; set; } = [];

[JsonProperty("podcast_slider_items_ids")]
public List<string> PodcastSliderItemsIds { get; set; } = new List<string>();
public List<string> PodcastSliderItemsIds { get; set; } = [];

[JsonProperty("longreads_ids")]
public List<string> LongreadsIds { get; set; } = new List<string>();
public List<string> LongreadsIds { get; set; } = [];

[JsonProperty("videos_ids")]
public List<string> VideosIds { get; set; } = new List<string>();
public List<string> VideosIds { get; set; } = [];

[JsonProperty("artist_videos_ids")]
public List<string> ArtistVideosIds { get; set; } = new List<string>();
public List<string> ArtistVideosIds { get; set; } = [];

[JsonProperty("placeholder_ids")]
public List<string> PlaceholdersIds { get; set; } = new List<string>();
public List<string> PlaceholdersIds { get; set; } = [];

[JsonProperty("music_owners_ids")]
public List<string> MusicOwnerIds { get; set; } = new List<string>();
public List<string> MusicOwnerIds { get; set; } = [];

[JsonProperty("audio_followings_update_info_ids")]
public List<string> FollowingUpdateInfoIds { get; set; } = new List<string>();
public List<string> FollowingUpdateInfoIds { get; set; } = [];

[JsonProperty("group_items")]
public List<CuratorGroup> GroupsItemsIds { get; set; } = new List<CuratorGroup>();

public List<Curator> Curators { get; set; } = new List<Curator>();
public List<Text> Texts { get; set; } = new List<Text>();
public List<Audio> Audios { get; set; } = new List<Audio>();
public List<Playlist> Playlists { get; set; } = new List<Playlist>();
public List<CatalogBanner> Banners { get; set; } = new List<CatalogBanner>();
public List<Link> Links { get; set; } = new List<Link>();
public List<Suggestion> Suggestions { get; set; } = new List<Suggestion>();
public List<Artist> Artists { get; set; } = new List<Artist>();
public List<Group> Groups { get; set; } = new List<Group>();
public List<PodcastSliderItem> PodcastSliderItems { get; set; } = new List<PodcastSliderItem>();
public List<PodcastEpisode> PodcastEpisodes { get; set; } = new List<PodcastEpisode>();
public List<Longread> Longreads { get; set; } = new List<Longread>();
public List<RecommendedPlaylist> RecommendedPlaylists { get; set; } = new List<RecommendedPlaylist>();
public List<Video> Videos { get; set; } = new List<Video>();
public List<Video> ArtistVideos { get; set; } = new List<Video>();

public List<Placeholder> Placeholders { get; set; } = new List<Placeholder>();

public List<MusicOwner> MusicOwners { get; set; } = new List<MusicOwner>();
public List<CuratorGroup> GroupsItemsIds { get; set; } = [];

public List<Curator> Curators { get; set; } = [];
public List<Text> Texts { get; set; } = [];
public List<Audio> Audios { get; set; } = [];
public List<Playlist> Playlists { get; set; } = [];
public List<CatalogBanner> Banners { get; set; } = [];
public List<Link> Links { get; set; } = [];
public List<Suggestion> Suggestions { get; set; } = [];
public List<Artist> Artists { get; set; } = [];
public List<Group> Groups { get; set; } = [];
public List<PodcastSliderItem> PodcastSliderItems { get; set; } = [];
public List<PodcastEpisode> PodcastEpisodes { get; set; } = [];
public List<Longread> Longreads { get; set; } = [];
public List<RecommendedPlaylist> RecommendedPlaylists { get; set; } = [];
public List<Video> Videos { get; set; } = [];
public List<Video> ArtistVideos { get; set; } = [];

public List<Placeholder> Placeholders { get; set; } = [];

public List<MusicOwner> MusicOwners { get; set; } = [];

public List<AudioFollowingsUpdateInfo> FollowingsUpdateInfos { get; set; } = new List<AudioFollowingsUpdateInfo>();

public List<Station> Stations { get; set; } = new List<Station>();
public List<AudioFollowingsUpdateInfo> FollowingsUpdateInfos { get; set; } = [];

public List<Station> Stations { get; set; } = [];

public Block Clone()
{
return (Block)MemberwiseClone();
}

public void Merge(Block block)
{
CatalogBannerIds.AddRange(block.CatalogBannerIds);
LinksIds.AddRange(block.LinksIds);
Buttons.AddRange(block.Buttons);
Actions.AddRange(block.Actions);
NextFrom = block.NextFrom;
Url = block.Url;
ListenEvents.AddRange(block.ListenEvents);
PlaylistsIds.AddRange(block.PlaylistsIds);
ArtistsIds.AddRange(block.ArtistsIds);
Badge = block.Badge;
AudiosIds.AddRange(block.AudiosIds);
CuratorsIds.AddRange(block.CuratorsIds);
GroupIds.AddRange(block.GroupIds);
TextIds.AddRange(block.TextIds);
PodcastEpisodesIds.AddRange(block.PodcastEpisodesIds);
PodcastSliderItemsIds.AddRange(block.PodcastSliderItemsIds);
LongreadsIds.AddRange(block.LongreadsIds);
VideosIds.AddRange(block.VideosIds);
ArtistVideosIds.AddRange(block.ArtistVideosIds);
PlaceholdersIds.AddRange(block.PlaceholdersIds);
MusicOwnerIds.AddRange(block.MusicOwnerIds);
FollowingUpdateInfoIds.AddRange(block.FollowingUpdateInfoIds);
GroupsItemsIds.AddRange(block.GroupsItemsIds);
Curators.AddRange(block.Curators);
Texts.AddRange(block.Texts);
Audios.AddRange(block.Audios);
Playlists.AddRange(block.Playlists);
Banners.AddRange(block.Banners);
Links.AddRange(block.Links);
Suggestions.AddRange(block.Suggestions);
Artists.AddRange(block.Artists);
Groups.AddRange(block.Groups);
PodcastSliderItems.AddRange(block.PodcastSliderItems);
PodcastEpisodes.AddRange(block.PodcastEpisodes);
Longreads.AddRange(block.Longreads);
Videos.AddRange(block.Videos);
ArtistVideos.AddRange(block.ArtistVideos);
Placeholders.AddRange(block.Placeholders);
MusicOwners.AddRange(block.MusicOwners);
FollowingsUpdateInfos.AddRange(block.FollowingsUpdateInfos);
RecommendedPlaylists.AddRange(block.RecommendedPlaylists);
Stations.AddRange(block.Stations);
}
}
}
2 changes: 1 addition & 1 deletion MusicX.Core/Models/Video.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace MusicX.Core.Models
{
public class Video : IIdentifiable
{
string IIdentifiable.Identifier => Id.ToString();
string IIdentifiable.Identifier => $"{OwnerId}_{Id}";

[JsonProperty("is_explicit")]
public int IsExplicit { get; set; }
Expand Down
6 changes: 5 additions & 1 deletion MusicX.Core/Services/VkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ public async Task DeletePlaylistAsync(long playlistId, long ownerId)
}
}

public async Task<ResponseData> AudioGetAsync(long? playlistId, long? ownerId, string? assessKey, long offset = 0, long count = 100)
public async Task<ResponseData> AudioGetAsync(long? playlistId, long? ownerId, string? assessKey, long offset = 0, long count = 100, int? shuffleSeed = null)
{
try
{
Expand Down Expand Up @@ -573,6 +573,10 @@ public async Task<ResponseData> AudioGetAsync(long? playlistId, long? ownerId, s
parameters.Add("access_key", assessKey);
}

if (shuffleSeed != null)
{
parameters.Add("shuffle_seed", shuffleSeed);
}

var model = await apiInvoke.CallAsync<ResponseData>("audio.get", parameters);

Expand Down
3 changes: 3 additions & 0 deletions MusicX/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
using MusicX.Patches;
using MusicX.Services;
using MusicX.Views;

Expand Down Expand Up @@ -41,6 +42,8 @@ protected async override void OnStartup(StartupEventArgs e)
{"Version", StaticService.Version }
};
Analytics.TrackEvent("StartApp", properties);

ItemContainerGeneratorIndexHook.Apply();

var window = new StartingWindow(e.Args);
window.Show();
Expand Down
7 changes: 4 additions & 3 deletions MusicX/Controls/ActionButtonControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Windows.Navigation;
using System.Windows.Shapes;
using MusicX.Core.Models;
using MusicX.ViewModels;
using MusicX.ViewModels.Controls;
using Block = MusicX.Core.Models.Block;
using Button = MusicX.Core.Models.Button;
Expand Down Expand Up @@ -42,11 +43,11 @@ public Artist? Artist
get => (Artist?)GetValue(ArtistProperty);
set => SetValue(ArtistProperty, value);
}
public static readonly DependencyProperty ParentBlockProperty = DependencyProperty.Register(nameof(ParentBlock), typeof(Block), typeof(ActionButtonControl), new(null, OnChanged));
public static readonly DependencyProperty ParentBlockProperty = DependencyProperty.Register(nameof(ParentBlock), typeof(BlockViewModel), typeof(ActionButtonControl), new(null, OnChanged));

public Block? ParentBlock
public BlockViewModel? ParentBlock
{
get => (Block?)GetValue(ParentBlockProperty);
get => (BlockViewModel?)GetValue(ParentBlockProperty);
set => SetValue(ParentBlockProperty, value);
}

Expand Down
11 changes: 9 additions & 2 deletions MusicX/Controls/BigBannerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ namespace MusicX.Controls
/// </summary>
public partial class BigBannerControl : UserControl
{
public static readonly DependencyProperty BannersProperty = DependencyProperty.Register(
nameof(Banners), typeof(IList<CatalogBanner>), typeof(BigBannerControl), new PropertyMetadata(Array.Empty<CatalogBanner>()));

public IList<CatalogBanner> Banners
{
get => (IList<CatalogBanner>)GetValue(BannersProperty);
set => SetValue(BannersProperty, value);
}

public BigBannerControl()
{
InitializeComponent();
Expand Down Expand Up @@ -75,8 +84,6 @@ private void BannerService_ShowBannerEvent(CatalogBanner banner)
amim.Begin();
}

public List<CatalogBanner> Banners => ((Block)DataContext).Banners;

private async void ActionButton_Click(object sender, RoutedEventArgs e)
{
try
Expand Down
Loading