Skip to content

Commit c60a820

Browse files
chore: configureawait
1 parent f28f353 commit c60a820

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

src/TwitchStreamingTools/Services/TwitchAccountService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public TwitchAccountService(ITwitchClientProxy twitchClient, IConfiguration conf
4242
Interval = TimeSpan.FromSeconds(5)
4343
};
4444

45-
_timer.Tick += async (_, _) => await OnCheckCredentials();
45+
_timer.Tick += async (_, _) => await OnCheckCredentials().ConfigureAwait(false);
4646
_ = OnCheckCredentials();
4747
}
4848

@@ -72,7 +72,7 @@ public async Task UpdateCredentials(string bearer, string refresh, DateTime expi
7272

7373
User? user = null;
7474
try {
75-
user = await twitchApi.GetUser();
75+
user = await twitchApi.GetUser().ConfigureAwait(false);
7676
}
7777
catch {
7878
// Do nothing
@@ -86,7 +86,7 @@ public async Task UpdateCredentials(string bearer, string refresh, DateTime expi
8686
_twitchClient.TwitchOAuthToken = bearer;
8787

8888
OnCredentialsChanged?.Invoke(oauth);
89-
await OnCheckCredentials();
89+
await OnCheckCredentials().ConfigureAwait(false);
9090
}
9191

9292
/// <inheritdoc />
@@ -113,11 +113,11 @@ private async Task OnCheckCredentials() {
113113

114114
try {
115115
// Refresh the token
116-
await DoTokenRefreshIfNearExpiration();
116+
await DoTokenRefreshIfNearExpiration().ConfigureAwait(false);
117117

118118
// Make sure the new token works
119119
var twitchApi = new TwitchApiWrapper();
120-
string? username = (await twitchApi.GetUser())?.Login;
120+
string? username = (await twitchApi.GetUser().ConfigureAwait(false))?.Login;
121121

122122
// Update the credentials
123123
CredentialsAreValid = !string.IsNullOrWhiteSpace(username);
@@ -157,7 +157,7 @@ private async Task DoTokenRefreshIfNearExpiration() {
157157
}
158158

159159
// Refresh the token
160-
await twitchApi.RefreshAccessToken();
160+
await twitchApi.RefreshAccessToken().ConfigureAwait(false);
161161

162162
// Update the configuration
163163
_configuration.OAuth = new TwitchAccessToken {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
1+
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib"
2+
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xml:space="preserve">
24
<s:String x:Key="/Default/CodeInspection/Daemon/ConfigureAwaitAnalysisMode/@EntryValue">Library</s:String></wpf:ResourceDictionary>

src/TwitchStreamingTools/Utilities/TwitchApiWrapper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ public TwitchApiWrapper() : base(
4242
try {
4343
// If the secret is specified, then this isn't using our API to authenticate, it's using the twitch api directly.
4444
if (!string.IsNullOrWhiteSpace(TwitchAppConfig?.ClientSecret)) {
45-
await base.RefreshAccessToken(token);
45+
await base.RefreshAccessToken(token).ConfigureAwait(false);
4646
}
4747

4848
using var client = new HttpClient();
4949
string url = $"{Constants.API_SITE_DOMAIN}/api/v1/user/twitch-login/twitch-streaming-tools";
5050
var request = new HttpRequestMessage(HttpMethod.Post, url);
5151
var values = new Dictionary<string, string> { { "refreshToken", OAuth?.RefreshToken ?? string.Empty } };
5252
var content = new FormUrlEncodedContent(values);
53-
using HttpResponseMessage response = await client.PostAsync(request.RequestUri, content, token);
53+
using HttpResponseMessage response = await client.PostAsync(request.RequestUri, content, token).ConfigureAwait(false);
5454
response.EnsureSuccessStatusCode();
55-
string responseBody = await response.Content.ReadAsStringAsync(token);
55+
string responseBody = await response.Content.ReadAsStringAsync(token).ConfigureAwait(false);
5656
var oauthResp = JsonConvert.DeserializeObject<TwitchAccessToken>(responseBody);
5757
if (null == oauthResp) {
5858
return null;

src/TwitchStreamingTools/ViewModels/NewVersionWindowViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public NewVersionWindowViewModel() {
4747
// asynchronously determine the current version number.
4848
Task.Factory.StartNew(async () => {
4949
GithubLatestReleaseJson? version =
50-
await GitHubUpdateManager.GetLatestVersion("nullinside-development-group", "twitch-streaming-tools");
50+
await GitHubUpdateManager.GetLatestVersion("nullinside-development-group", "twitch-streaming-tools").ConfigureAwait(false);
5151

5252
if (null == version) {
5353
return;

src/TwitchStreamingTools/ViewModels/Pages/AccountViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private async void OnCredentialsChanged(TwitchAccessToken? token) {
181181
ProfileImage = null;
182182
return;
183183
}
184-
184+
185185
await LoadProfileImage().ConfigureAwait(false);
186186
}
187187
catch (Exception ex) {
@@ -286,14 +286,14 @@ private void ClearCredentials() {
286286
if (!Directory.Exists(PROFILE_IMAGE_FOLDER)) {
287287
Directory.CreateDirectory(PROFILE_IMAGE_FOLDER);
288288
}
289-
289+
290290
// I don't think twitch usernames can have non-filepath friendly characters but might as well sanitize it anyway.
291291
string filename = SanitizeFilename(string.Format(PROFILE_IMAGE_FILENAME, user.Login));
292292
string imagePath = Path.Combine(PROFILE_IMAGE_FOLDER, filename);
293-
293+
294294
// Save to disk
295295
await File.WriteAllBytesAsync(imagePath, imageBytes, token).ConfigureAwait(false);
296-
296+
297297
// Return path to file, even though everyone already knows it.
298298
return imagePath;
299299
}, 10, token, TimeSpan.FromSeconds(1)).ConfigureAwait(false);

src/TwitchStreamingTools/ViewModels/Pages/SettingsView/TtsSkipUsernamesViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ private async void UserListRefreshTimer_OnElapsed(object sender, ElapsedEventArg
150150
}
151151

152152
try {
153-
(string? id, string? username) userInfo = await api.GetUser(chat.TwitchChannel);
153+
(string? id, string? username) userInfo = await api.GetUser(chat.TwitchChannel).ConfigureAwait(false);
154154
if (null == userInfo.id || null == loggedInUser?.Id) {
155155
continue;
156156
}
157157

158-
IEnumerable<Chatter> chatters = await api.GetChannelUsers(userInfo.id, loggedInUser.Id);
158+
IEnumerable<Chatter> chatters = await api.GetChannelUsers(userInfo.id, loggedInUser.Id).ConfigureAwait(false);
159159
foreach (Chatter chatter in chatters) {
160160
usernames.Add(chatter.UserName.ToLowerInvariant());
161161
}

src/TwitchStreamingTools/Views/WindowsTitleBar.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private async void SubscribeToWindowState() {
110110

111111
while (hostWindow == null) {
112112
hostWindow = VisualRoot as Window;
113-
await Task.Delay(50);
113+
await Task.Delay(50).ConfigureAwait(false);
114114
}
115115

116116
hostWindow.GetObservable(Window.WindowStateProperty).Subscribe(s => {

0 commit comments

Comments
 (0)