@@ -143,7 +143,7 @@ public override async void OnLoaded() {
143
143
base . OnLoaded ( ) ;
144
144
145
145
try {
146
- await LoadProfileImage ( ) ;
146
+ await LoadProfileImage ( ) . ConfigureAwait ( false ) ;
147
147
}
148
148
catch ( Exception ex ) {
149
149
_logger . Error ( "Failed to load profile image" , ex ) ;
@@ -162,7 +162,7 @@ private async Task LoadProfileImage() {
162
162
}
163
163
164
164
// If we couldn't find the file, download it.
165
- profileImagePath = await DownloadUserImage ( ) ;
165
+ profileImagePath = await DownloadUserImage ( ) . ConfigureAwait ( false ) ;
166
166
if ( null == profileImagePath ) {
167
167
return ;
168
168
}
@@ -177,10 +177,11 @@ private async Task LoadProfileImage() {
177
177
private async void OnCredentialsChanged ( TwitchAccessToken ? token ) {
178
178
try {
179
179
if ( string . IsNullOrWhiteSpace ( token ? . AccessToken ) ) {
180
+ ProfileImage = null ;
180
181
return ;
181
182
}
182
-
183
- await LoadProfileImage ( ) ;
183
+
184
+ await LoadProfileImage ( ) . ConfigureAwait ( false ) ;
184
185
}
185
186
catch ( Exception ex ) {
186
187
_logger . Error ( "Failed to download user profile image" , ex ) ;
@@ -219,8 +220,8 @@ private async void PerformLogin() {
219
220
220
221
// Create a web socket connection to the api which will provide us with the credentials from twitch.
221
222
ClientWebSocket webSocket = new ( ) ;
222
- await webSocket . ConnectAsync ( new Uri ( $ "ws://{ Constants . DOMAIN } /api/v1/user/twitch-login/twitch-streaming-tools/ws") , token ) ;
223
- await webSocket . SendTextAsync ( guid . ToString ( ) , token ) ;
223
+ await webSocket . ConnectAsync ( new Uri ( $ "ws://{ Constants . DOMAIN } /api/v1/user/twitch-login/twitch-streaming-tools/ws") , token ) . ConfigureAwait ( false ) ;
224
+ await webSocket . SendTextAsync ( guid . ToString ( ) , token ) . ConfigureAwait ( false ) ;
224
225
225
226
// Launch the web browser to twitch to ask for account permissions. Twitch will be instructed to callback to our
226
227
// api (redirect_uri) which will give us the credentials on the web socket above.
@@ -233,10 +234,10 @@ private async void PerformLogin() {
233
234
234
235
// Wait for the user to finish giving us permission on the website. Once they provide us access we will receive
235
236
// a response on the web socket containing a JSON with our OAuth information.
236
- string json = await webSocket . ReceiveTextAsync ( token ) ;
237
+ string json = await webSocket . ReceiveTextAsync ( token ) . ConfigureAwait ( false ) ;
237
238
238
239
// Close the connection, both sides will be waiting to do this so we do it immediately.
239
- await webSocket . CloseAsync ( WebSocketCloseStatus . NormalClosure , "Completed Successfully!" , token ) ;
240
+ await webSocket . CloseAsync ( WebSocketCloseStatus . NormalClosure , "Completed Successfully!" , token ) . ConfigureAwait ( false ) ;
240
241
241
242
// Update the oauth token in the twitch account service.
242
243
var oauthResp = JsonConvert . DeserializeObject < TwitchAccessToken > ( json ) ;
@@ -245,7 +246,7 @@ private async void PerformLogin() {
245
246
return ;
246
247
}
247
248
248
- await _twitchAccountService . UpdateCredentials ( oauthResp . AccessToken , oauthResp . RefreshToken , oauthResp . ExpiresUtc . Value ) ;
249
+ await _twitchAccountService . UpdateCredentials ( oauthResp . AccessToken , oauthResp . RefreshToken , oauthResp . ExpiresUtc . Value ) . ConfigureAwait ( false ) ;
249
250
}
250
251
catch ( Exception ex ) {
251
252
_logger . Error ( "Failed to launch browser to login" , ex ) ;
@@ -270,14 +271,14 @@ private void ClearCredentials() {
270
271
return null ;
271
272
}
272
273
273
- User ? user = await api . GetUser ( ) ;
274
+ User ? user = await api . GetUser ( ) . ConfigureAwait ( false ) ;
274
275
if ( string . IsNullOrWhiteSpace ( user ? . ProfileImageUrl ) ) {
275
276
return null ;
276
277
}
277
278
278
279
// Download the image via http.
279
280
using var http = new HttpClient ( ) ;
280
- byte [ ] imageBytes = await http . GetByteArrayAsync ( user . ProfileImageUrl ) ;
281
+ byte [ ] imageBytes = await http . GetByteArrayAsync ( user . ProfileImageUrl ) . ConfigureAwait ( false ) ;
281
282
282
283
// If the directory doesn't exist, create it.
283
284
if ( ! Directory . Exists ( PROFILE_IMAGE_FOLDER ) ) {
@@ -289,7 +290,7 @@ private void ClearCredentials() {
289
290
string imagePath = Path . Combine ( PROFILE_IMAGE_FOLDER , filename ) ;
290
291
291
292
// Save to disk
292
- await File . WriteAllBytesAsync ( imagePath , imageBytes ) ;
293
+ await File . WriteAllBytesAsync ( imagePath , imageBytes ) . ConfigureAwait ( false ) ;
293
294
294
295
// Return path to file, even though everyone already knows it.
295
296
return imagePath ;
0 commit comments