diff --git a/src/TwitchStreamingTools/ViewModels/Pages/AccountViewModel.cs b/src/TwitchStreamingTools/ViewModels/Pages/AccountViewModel.cs
index 46ce9d9..3b3abd7 100644
--- a/src/TwitchStreamingTools/ViewModels/Pages/AccountViewModel.cs
+++ b/src/TwitchStreamingTools/ViewModels/Pages/AccountViewModel.cs
@@ -56,11 +56,21 @@ public class AccountViewModel : PageViewModelBase, IDisposable {
///
private readonly ITwitchAccountService _twitchAccountService;
+ ///
+ /// True if currently downloading the logged in user's profile photo, false otherwise.
+ ///
+ private bool _downloadingProfileImage;
+
///
/// True if we have a valid OAuth token, false otherwise.
///
private bool _hasValidOAuthToken;
+ ///
+ /// True if currently in the logging in process, false otherwise.
+ ///
+ private bool _loggingIn;
+
///
/// The profile image of the logged in user.
///
@@ -110,6 +120,22 @@ public Bitmap? ProfileImage {
///
public ReactiveCommand OnLogout { get; }
+ ///
+ /// True if currently in the logging in process, false otherwise.
+ ///
+ public bool LoggingIn {
+ get => _loggingIn;
+ set => this.RaiseAndSetIfChanged(ref _loggingIn, value);
+ }
+
+ ///
+ /// True if currently downloading the logged in user's profile photo, false otherwise.
+ ///
+ public bool DownloadingProfileImage {
+ get => _downloadingProfileImage;
+ set => this.RaiseAndSetIfChanged(ref _downloadingProfileImage, value);
+ }
+
///
/// True if we have a valid OAuth token, false otherwise.
///
@@ -157,18 +183,21 @@ public override async void OnLoaded() {
private async Task LoadProfileImage() {
// Try to get the file locally.
string? profileImagePath = string.Format(PROFILE_IMAGE_FILENAME, _configuration.TwitchUsername);
+ profileImagePath = Path.Combine(PROFILE_IMAGE_FOLDER, profileImagePath);
if (File.Exists(profileImagePath)) {
ProfileImage = new Bitmap(profileImagePath);
return;
}
// If we couldn't find the file, download it.
+ DownloadingProfileImage = true;
profileImagePath = await DownloadUserImage().ConfigureAwait(false);
if (null == profileImagePath) {
return;
}
ProfileImage = new Bitmap(profileImagePath);
+ DownloadingProfileImage = false;
}
///
@@ -213,6 +242,7 @@ private void OnCredentialsStatusChanged(bool valid) {
/// Launches the computer's default browser to generate an OAuth token.
///
private async void PerformLogin() {
+ LoggingIn = true;
try {
CancellationToken token = CancellationToken.None;
@@ -252,6 +282,9 @@ private async void PerformLogin() {
catch (Exception ex) {
_logger.Error("Failed to launch browser to login", ex);
}
+ finally {
+ LoggingIn = false;
+ }
}
///
diff --git a/src/TwitchStreamingTools/Views/Pages/AccountView.axaml b/src/TwitchStreamingTools/Views/Pages/AccountView.axaml
index 38d5cd8..6fdac17 100644
--- a/src/TwitchStreamingTools/Views/Pages/AccountView.axaml
+++ b/src/TwitchStreamingTools/Views/Pages/AccountView.axaml
@@ -3,6 +3,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:TwitchStreamingTools.ViewModels.Pages"
+ xmlns:controls="clr-namespace:TwitchStreamingTools.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="TwitchStreamingTools.Views.Pages.AccountView"
x:DataType="pages:AccountViewModel">
@@ -24,16 +25,19 @@
DockPanel.Dock="Top"
Spacing="15">
+
-
-
-
+
+
+
+