diff --git a/MixItUp.Base/ViewModel/MainControls/ChannelMainControlViewModel.cs b/MixItUp.Base/ViewModel/MainControls/ChannelMainControlViewModel.cs index 273fcc5f0..460617048 100644 --- a/MixItUp.Base/ViewModel/MainControls/ChannelMainControlViewModel.cs +++ b/MixItUp.Base/ViewModel/MainControls/ChannelMainControlViewModel.cs @@ -1,7 +1,9 @@ -using MixItUp.Base.Model; +using Google.Apis.YouTube.v3.Data; +using MixItUp.Base.Model; using MixItUp.Base.Services; using MixItUp.Base.Services.Trovo; using MixItUp.Base.Services.Twitch; +using MixItUp.Base.Services.YouTube; using MixItUp.Base.Util; using MixItUp.Base.ViewModel.Twitch; using MixItUp.Base.ViewModels; @@ -199,6 +201,64 @@ protected override async Task SearchChannelsToRaid() } } + public class YouTubeChannelControlViewModel : PlatformChannelControlViewModelBase + { + public string Description + { + get { return this.description; } + set + { + this.description = value; + this.NotifyPropertyChanged(); + } + } + private string description; + + public Video Video { get; private set; } + + public YouTubeChannelControlViewModel() { this.Platform = StreamingPlatformTypeEnum.YouTube; } + + protected override async Task OnOpenInternal() + { + await base.OnOpenInternal(); + + this.Video = ServiceManager.Get().Video; + if (this.Video != null) + { + if (!string.IsNullOrEmpty(ServiceManager.Get().Video.Snippet.Title)) + { + this.Title = ServiceManager.Get().Video.Snippet.Title; + } + + if (!string.IsNullOrEmpty(ServiceManager.Get().Video.Snippet.Description)) + { + this.Description = ServiceManager.Get().Video.Snippet.Description; + } + } + } + + protected override Task RefreshChannelInformation() { return Task.CompletedTask; } + + protected override async Task UpdateChannelInformation() + { + Video video = await ServiceManager.Get().UserConnection.UpdateVideo(this.Video, this.Title, this.Description); + if (video == null) + { + return new Result(MixItUp.Base.Resources.FailedToUpdateChannelInformation); + } + + this.Video = video; + this.UpdateRecentData(); + + return new Result(); + } + + protected override Task SearchChannelsToRaid() + { + return Task.CompletedTask; + } + } + public class TrovoChannelControlViewModel : PlatformChannelControlViewModelBase { public enum TrovoSearchFindChannelToRaidTypeEnum @@ -222,11 +282,6 @@ public TrovoSearchFindChannelToRaidTypeEnum SelectedSearchFindChannelToRaidOptio public TrovoChannelControlViewModel() { this.Platform = StreamingPlatformTypeEnum.Trovo; } - protected override async Task OnOpenInternal() - { - await base.OnOpenInternal(); - } - protected override async Task SearchChannelsToRaid() { this.ChannelsToRaid.Clear(); @@ -419,6 +474,13 @@ protected virtual async Task UpdateChannelInformation() return new Result(MixItUp.Base.Resources.FailedToUpdateChannelInformation); } + this.UpdateRecentData(); + + return new Result(); + } + + protected void UpdateRecentData() + { ChannelSession.Settings.RecentStreamTitles.Insert(0, this.Title); while (ChannelSession.Settings.RecentStreamTitles.Count > 10) { @@ -432,8 +494,6 @@ protected virtual async Task UpdateChannelInformation() this.PastTitles.ClearAndAddRange(ChannelSession.Settings.RecentStreamTitles); this.PastCategories.ClearAndAddRange(ChannelSession.Settings.RecentStreamCategories); - - return new Result(); } protected abstract Task SearchChannelsToRaid(); @@ -443,10 +503,14 @@ public class ChannelMainControlViewModel : WindowControlViewModelBase { public TwitchChannelControlViewModel Twitch { get; set; } = new TwitchChannelControlViewModel(); + public YouTubeChannelControlViewModel YouTube { get; set; } = new YouTubeChannelControlViewModel(); + public TrovoChannelControlViewModel Trovo { get; set; } = new TrovoChannelControlViewModel(); public bool IsTwitchConnected { get { return ServiceManager.Get().IsConnected; } } + public bool IsYouTubeConnected { get { return ServiceManager.Get().IsConnected; } } + public bool IsTrovoConnected { get { return ServiceManager.Get().IsConnected; } } public ChannelMainControlViewModel(MainWindowViewModel windowViewModel) : base(windowViewModel) { } @@ -458,6 +522,11 @@ protected override async Task OnOpenInternal() await this.Twitch.OnOpen(); } + if (this.IsYouTubeConnected) + { + await this.YouTube.OnOpen(); + } + if (this.IsTrovoConnected) { await this.Trovo.OnOpen(); @@ -473,6 +542,11 @@ protected override async Task OnVisibleInternal() await this.Twitch.OnVisible(); } + if (this.IsYouTubeConnected) + { + await this.YouTube.OnVisible(); + } + if (this.IsTrovoConnected) { await this.Trovo.OnVisible(); diff --git a/MixItUp.WPF/Controls/MainControls/ChannelControl.xaml b/MixItUp.WPF/Controls/MainControls/ChannelControl.xaml index 140e210dd..7517e2125 100644 --- a/MixItUp.WPF/Controls/MainControls/ChannelControl.xaml +++ b/MixItUp.WPF/Controls/MainControls/ChannelControl.xaml @@ -130,6 +130,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +