Crunchy-Downloader/CRD/ViewModels/Utils/ContentDialogInputLoginViewModel.cs
Elwador 15c62193ca - Added **second endpoint settings** that can be freely adjusted
- Added basic **poster (tall and wide) download** for history series
- Changed **download list** so that episode titles are highlighted if possibly all dubs/subs are available
2025-09-06 17:39:20 +02:00

47 lines
No EOL
1.6 KiB
C#

using System;
using CommunityToolkit.Mvvm.ComponentModel;
using CRD.Downloader.Crunchyroll;
using CRD.Utils.Structs;
using FluentAvalonia.UI.Controls;
namespace CRD.ViewModels.Utils;
public partial class ContentDialogInputLoginViewModel : ViewModelBase{
private readonly ContentDialog dialog;
[ObservableProperty]
private string _email;
[ObservableProperty]
private string _password;
private AccountPageViewModel accountPageViewModel;
public ContentDialogInputLoginViewModel(ContentDialog dialog, AccountPageViewModel accountPageViewModel = null){
if (dialog is null){
throw new ArgumentNullException(nameof(dialog));
}
this.dialog = dialog;
dialog.Closed += DialogOnClosed;
dialog.PrimaryButtonClick += LoginButton;
this.accountPageViewModel = accountPageViewModel;
}
private async void LoginButton(ContentDialog sender, ContentDialogButtonClickEventArgs args){
dialog.PrimaryButtonClick -= LoginButton;
await CrunchyrollManager.Instance.CrAuthEndpoint1.Auth(new AuthData{Password = Password,Username = Email});
if (!string.IsNullOrEmpty(CrunchyrollManager.Instance.CrAuthEndpoint2.AuthSettings.Endpoint)){
await CrunchyrollManager.Instance.CrAuthEndpoint2.Auth(new AuthData{Password = Password,Username = Email});
}
if (accountPageViewModel != null){
accountPageViewModel.UpdatetProfile();
}
}
private void DialogOnClosed(ContentDialog sender, ContentDialogClosedEventArgs args){
dialog.Closed -= DialogOnClosed;
}
}