@@ -56,11 +56,21 @@ public class AccountViewModel : PageViewModelBase, IDisposable {
5656 /// </summary>
5757 private readonly ITwitchAccountService _twitchAccountService ;
5858
59+ /// <summary>
60+ /// True if currently downloading the logged in user's profile photo, false otherwise.
61+ /// </summary>
62+ private bool _downloadingProfileImage ;
63+
5964 /// <summary>
6065 /// True if we have a valid OAuth token, false otherwise.
6166 /// </summary>
6267 private bool _hasValidOAuthToken ;
6368
69+ /// <summary>
70+ /// True if currently in the logging in process, false otherwise.
71+ /// </summary>
72+ private bool _loggingIn ;
73+
6474 /// <summary>
6575 /// The profile image of the logged in user.
6676 /// </summary>
@@ -110,6 +120,22 @@ public Bitmap? ProfileImage {
110120 /// </summary>
111121 public ReactiveCommand < Unit , Unit > OnLogout { get ; }
112122
123+ /// <summary>
124+ /// True if currently in the logging in process, false otherwise.
125+ /// </summary>
126+ public bool LoggingIn {
127+ get => _loggingIn ;
128+ set => this . RaiseAndSetIfChanged ( ref _loggingIn , value ) ;
129+ }
130+
131+ /// <summary>
132+ /// True if currently downloading the logged in user's profile photo, false otherwise.
133+ /// </summary>
134+ public bool DownloadingProfileImage {
135+ get => _downloadingProfileImage ;
136+ set => this . RaiseAndSetIfChanged ( ref _downloadingProfileImage , value ) ;
137+ }
138+
113139 /// <summary>
114140 /// True if we have a valid OAuth token, false otherwise.
115141 /// </summary>
@@ -157,18 +183,21 @@ public override async void OnLoaded() {
157183 private async Task LoadProfileImage ( ) {
158184 // Try to get the file locally.
159185 string ? profileImagePath = string . Format ( PROFILE_IMAGE_FILENAME , _configuration . TwitchUsername ) ;
186+ profileImagePath = Path . Combine ( PROFILE_IMAGE_FOLDER , profileImagePath ) ;
160187 if ( File . Exists ( profileImagePath ) ) {
161188 ProfileImage = new Bitmap ( profileImagePath ) ;
162189 return ;
163190 }
164191
165192 // If we couldn't find the file, download it.
193+ DownloadingProfileImage = true ;
166194 profileImagePath = await DownloadUserImage ( ) . ConfigureAwait ( false ) ;
167195 if ( null == profileImagePath ) {
168196 return ;
169197 }
170198
171199 ProfileImage = new Bitmap ( profileImagePath ) ;
200+ DownloadingProfileImage = false ;
172201 }
173202
174203 /// <summary>
@@ -213,6 +242,7 @@ private void OnCredentialsStatusChanged(bool valid) {
213242 /// Launches the computer's default browser to generate an OAuth token.
214243 /// </summary>
215244 private async void PerformLogin ( ) {
245+ LoggingIn = true ;
216246 try {
217247 CancellationToken token = CancellationToken . None ;
218248
@@ -252,6 +282,9 @@ private async void PerformLogin() {
252282 catch ( Exception ex ) {
253283 _logger . Error ( "Failed to launch browser to login" , ex ) ;
254284 }
285+ finally {
286+ LoggingIn = false ;
287+ }
255288 }
256289
257290 /// <summary>
0 commit comments