diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/AuthenticationViewResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/AuthenticationViewResources.resw
index f1c32dd..5943cab 100644
--- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/AuthenticationViewResources.resw
+++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/AuthenticationViewResources.resw
@@ -117,10 +117,10 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
Sign in
-
+
Sign out
@@ -135,9 +135,18 @@
Token expired or is invalid. Please log in again
+
+ Cannot validate token. Check your internet connection and try again later.
+
You are not authenticated. Please sign in
+
+ You are not authenticated and there is no internet connection. Check your internet connection and try again later.
+
+
+ An unknown error occured during Twitch login
+
Twitch authentication error
diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeViewResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeViewResources.resw
index 8462c2e..6096f2a 100644
--- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeViewResources.resw
+++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeViewResources.resw
@@ -120,6 +120,15 @@
Error
+
+ No internet connection
+
+
+ Cancel all
+
+
+ 80
+
Download all
diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SearchResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SearchResources.resw
index 093321f..bb15590 100644
--- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SearchResources.resw
+++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SearchResources.resw
@@ -123,6 +123,9 @@
Invalid url. Url cannot be empty.
+
+ Search timeout. Check your internet connection.
+
Invalid url. Url does not match any of supported source.
diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SubscriptionsViewResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SubscriptionsViewResources.resw
index 1e97e5b..8f03e2f 100644
--- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SubscriptionsViewResources.resw
+++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SubscriptionsViewResources.resw
@@ -126,6 +126,9 @@
Subscriptions
+
+ No internet connection
+
Add
diff --git a/VDownload.Core/VDownload.Core.ViewModels/Authentication/AuthenticationViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Authentication/AuthenticationViewModel.cs
index 623cf20..4356c02 100644
--- a/VDownload.Core/VDownload.Core.ViewModels/Authentication/AuthenticationViewModel.cs
+++ b/VDownload.Core/VDownload.Core.ViewModels/Authentication/AuthenticationViewModel.cs
@@ -1,8 +1,10 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
+using CommunityToolkit.WinUI.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -44,10 +46,13 @@ namespace VDownload.Core.ViewModels.Authentication
#region PROPERTIES
[ObservableProperty]
- private AuthenticationButton _twitchButtonState = AuthenticationButton.Loading;
+ protected AuthenticationButton _twitchButtonState = AuthenticationButton.Loading;
[ObservableProperty]
- private string _twitchDescription;
+ protected bool _twitchButtonEnable = true;
+
+ [ObservableProperty]
+ protected string _twitchDescription;
#endregion
@@ -107,7 +112,9 @@ namespace VDownload.Core.ViewModels.Authentication
}
else
{
- await _dialogsService.ShowOk(_stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDialogTitle"), "An unknown error occured"); // TODO : Change to string resource
+ string title = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDialogTitle");
+ string message = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDialogMessage");
+ await _dialogsService.ShowOk(title, message);
}
}
await TwitchAuthenticationRefresh();
@@ -122,17 +129,38 @@ namespace VDownload.Core.ViewModels.Authentication
private async Task TwitchAuthenticationRefresh()
{
TwitchButtonState = AuthenticationButton.Loading;
+ TwitchButtonEnable = true;
byte[]? token = await _twitchAuthenticationService.GetToken();
if (token is null)
{
- TwitchDescription = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionNotAuthenticated");
+ if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
+ {
+ TwitchButtonEnable = false;
+ TwitchDescription = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionNotAuthenticatedNoInternetConnection");
+ }
+ else
+ {
+ TwitchDescription = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionNotAuthenticated");
+ }
TwitchButtonState = AuthenticationButton.SignIn;
}
else
{
- TwitchValidationResult validationResult = await _twitchAuthenticationService.ValidateToken(token);
+ TwitchValidationResult validationResult;
+ try
+ {
+ validationResult = await _twitchAuthenticationService.ValidateToken(token);
+ }
+ catch (Exception ex) when (ex is TaskCanceledException || ex is HttpRequestException)
+ {
+ TwitchDescription = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionCannotValidate");
+ TwitchButtonState = AuthenticationButton.SignIn;
+ TwitchButtonEnable = false;
+ return;
+ }
+
if (validationResult.Success)
{
TwitchDescription = string.Format(_stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionAuthenticated"), validationResult.TokenData.Login, validationResult.TokenData.ExpirationDate);
diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs
index a6bb706..1841391 100644
--- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs
+++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs
@@ -4,6 +4,7 @@ using CommunityToolkit.WinUI.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using VDownload.Core.Tasks;
@@ -163,46 +164,57 @@ namespace VDownload.Core.ViewModels.Home
[RelayCommand]
public async Task LoadFromSubscription()
{
- MainContent = _downloadsView;
- OptionBarLoading = false;
- OptionBarMessage = null;
+ SearchButtonClicked();
if (OptionBarLoadSubscriptionButtonChecked)
{
+ if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
+ {
+ ShowError(ErrorNoInternetConnection());
+ OptionBarLoadSubscriptionButtonChecked = false;
+ return;
+ }
+
OptionBarContent = OptionBarContentType.None;
OptionBarVideoSearchButtonChecked = false;
OptionBarPlaylistSearchButtonChecked = false;
- OptionBarSearchNotPending = false;
- OptionBarLoading = true;
- OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading");
+ StartSearch();
SubscriptionsVideoList subList = new SubscriptionsVideoList { Name = _stringResourcesService.CommonResources.Get("SubscriptionVideoListName") };
List tasks = new List();
- foreach (Subscription sub in _subscriptionsDataService.Data.ToArray())
+ try
{
- tasks.Add(Task.Run(async () =>
+ foreach (Subscription sub in _subscriptionsDataService.Data.ToArray())
{
- Playlist playlist;
- try
+ tasks.Add(Task.Run(async () =>
{
- playlist = await _searchService.SearchPlaylist(sub.Url.OriginalString, 0);
- }
- catch (MediaSearchException)
- {
- return;
- }
+ Playlist playlist;
+ try
+ {
+ playlist = await _searchService.SearchPlaylist(sub.Url.OriginalString, 0);
+ }
+ catch (MediaSearchException)
+ {
+ return;
+ }
- IEnumerable