@@ -56,11 +56,21 @@ public class AccountViewModel : PageViewModelBase, IDisposable {
56
56
/// </summary>
57
57
private readonly ITwitchAccountService _twitchAccountService ;
58
58
59
+ /// <summary>
60
+ /// True if currently downloading the logged in user's profile photo, false otherwise.
61
+ /// </summary>
62
+ private bool _downloadingProfileImage ;
63
+
59
64
/// <summary>
60
65
/// True if we have a valid OAuth token, false otherwise.
61
66
/// </summary>
62
67
private bool _hasValidOAuthToken ;
63
68
69
+ /// <summary>
70
+ /// True if currently in the logging in process, false otherwise.
71
+ /// </summary>
72
+ private bool _loggingIn ;
73
+
64
74
/// <summary>
65
75
/// The profile image of the logged in user.
66
76
/// </summary>
@@ -110,6 +120,22 @@ public Bitmap? ProfileImage {
110
120
/// </summary>
111
121
public ReactiveCommand < Unit , Unit > OnLogout { get ; }
112
122
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
+
113
139
/// <summary>
114
140
/// True if we have a valid OAuth token, false otherwise.
115
141
/// </summary>
@@ -157,18 +183,21 @@ public override async void OnLoaded() {
157
183
private async Task LoadProfileImage ( ) {
158
184
// Try to get the file locally.
159
185
string ? profileImagePath = string . Format ( PROFILE_IMAGE_FILENAME , _configuration . TwitchUsername ) ;
186
+ profileImagePath = Path . Combine ( PROFILE_IMAGE_FOLDER , profileImagePath ) ;
160
187
if ( File . Exists ( profileImagePath ) ) {
161
188
ProfileImage = new Bitmap ( profileImagePath ) ;
162
189
return ;
163
190
}
164
191
165
192
// If we couldn't find the file, download it.
193
+ DownloadingProfileImage = true ;
166
194
profileImagePath = await DownloadUserImage ( ) . ConfigureAwait ( false ) ;
167
195
if ( null == profileImagePath ) {
168
196
return ;
169
197
}
170
198
171
199
ProfileImage = new Bitmap ( profileImagePath ) ;
200
+ DownloadingProfileImage = false ;
172
201
}
173
202
174
203
/// <summary>
@@ -213,6 +242,7 @@ private void OnCredentialsStatusChanged(bool valid) {
213
242
/// Launches the computer's default browser to generate an OAuth token.
214
243
/// </summary>
215
244
private async void PerformLogin ( ) {
245
+ LoggingIn = true ;
216
246
try {
217
247
CancellationToken token = CancellationToken . None ;
218
248
@@ -252,6 +282,9 @@ private async void PerformLogin() {
252
282
catch ( Exception ex ) {
253
283
_logger . Error ( "Failed to launch browser to login" , ex ) ;
254
284
}
285
+ finally {
286
+ LoggingIn = false ;
287
+ }
255
288
}
256
289
257
290
/// <summary>
0 commit comments