Skip to content

Commit 18b9d98

Browse files
committed
refactor: remove ConfigureAwait when we need to go back to UIThread after it
Signed-off-by: leo <[email protected]>
1 parent 2a0f9f4 commit 18b9d98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+172
-399
lines changed

src/App.axaml.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,6 @@ public static void ShowWindow(object data, bool showAsDialog)
148148

149149
public static async Task<bool> AskConfirmAsync(string message, Action onSure)
150150
{
151-
if (!Dispatcher.UIThread.CheckAccess())
152-
{
153-
return await Dispatcher.UIThread.InvokeAsync<bool>(async () =>
154-
{
155-
return await AskConfirmAsync(message, onSure);
156-
});
157-
}
158-
159151
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } owner })
160152
{
161153
var confirm = new Views.Confirm();

src/Commands/Branch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static async Task<bool> DeleteRemoteAsync(string repo, string remote, str
6262
{
6363
bool exists = await new Remote(repo).HasBranchAsync(remote, name).ConfigureAwait(false);
6464
if (exists)
65-
return await new Push(repo, remote, $"refs/heads/{name}", true) { Log = log }.ExecAsync().ConfigureAwait(false);
65+
return await new Push(repo, remote, $"refs/heads/{name}", true) { Log = log }.RunAsync().ConfigureAwait(false);
6666

6767
var cmd = new Command();
6868
cmd.WorkingDirectory = repo;

src/ViewModels/AIAssistant.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ private void Gen()
6262
{
6363
await new Commands.GenerateCommitMessage(_service, _repo.FullPath, _changes, _cancel.Token, message =>
6464
{
65-
Dispatcher.UIThread.Invoke(() => Text = message);
66-
}).ExecAsync();
65+
Dispatcher.UIThread.Post(() => Text = message);
66+
}).ExecAsync().ConfigureAwait(false);
6767

68-
await Dispatcher.UIThread.InvokeAsync(() => IsGenerating = false);
68+
Dispatcher.UIThread.Post(() => IsGenerating = false);
6969
}, _cancel.Token);
7070
}
7171

src/ViewModels/AddRemote.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,17 @@ public override async Task<bool> Sure()
9797

9898
var succ = await new Commands.Remote(_repo.FullPath)
9999
.Use(log)
100-
.AddAsync(_name, _url)
101-
.ConfigureAwait(false);
100+
.AddAsync(_name, _url);
102101

103102
if (succ)
104103
{
105104
await new Commands.Config(_repo.FullPath)
106105
.Use(log)
107-
.SetAsync($"remote.{_name}.sshkey", _useSSH ? SSHKey : null)
108-
.ConfigureAwait(false);
106+
.SetAsync($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);
109107

110108
await new Commands.Fetch(_repo.FullPath, _name, false, false)
111109
.Use(log)
112-
.ExecAsync()
113-
.ConfigureAwait(false);
110+
.RunAsync();
114111
}
115112

116113
log.Complete();

src/ViewModels/AddSubmodule.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public override async Task<bool> Sure()
6161

6262
var succ = await new Commands.Submodule(_repo.FullPath)
6363
.Use(log)
64-
.AddAsync(_url, relativePath, Recursive)
65-
.ConfigureAwait(false);
64+
.AddAsync(_url, relativePath, Recursive);
6665

6766
log.Complete();
6867
_repo.SetWatcherEnabled(true);

src/ViewModels/AddWorktree.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ public override async Task<bool> Sure()
118118

119119
var succ = await new Commands.Worktree(_repo.FullPath)
120120
.Use(log)
121-
.AddAsync(_path, branchName, _createNewBranch, tracking)
122-
.ConfigureAwait(false);
121+
.AddAsync(_path, branchName, _createNewBranch, tracking);
123122

124123
log.Complete();
125124
_repo.SetWatcherEnabled(true);

src/ViewModels/Apply.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public override async Task<bool> Sure()
5151

5252
var succ = await new Commands.Apply(_repo.FullPath, _patchFile, _ignoreWhiteSpace, SelectedWhiteSpaceMode.Arg, null)
5353
.Use(log)
54-
.ExecAsync()
55-
.ConfigureAwait(false);
54+
.ExecAsync();
5655

5756
log.Complete();
5857
_repo.SetWatcherEnabled(true);

src/ViewModels/ApplyStash.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ public override async Task<bool> Sure()
3838

3939
var succ = await new Commands.Stash(_repo.FullPath)
4040
.Use(log)
41-
.ApplyAsync(Stash.Name, RestoreIndex)
42-
.ConfigureAwait(false);
41+
.ApplyAsync(Stash.Name, RestoreIndex);
4342

4443
if (succ && DropAfterApply)
4544
await new Commands.Stash(_repo.FullPath)
4645
.Use(log)
47-
.DropAsync(Stash.Name)
48-
.ConfigureAwait(false);
46+
.DropAsync(Stash.Name);
4947

5048
log.Complete();
5149
_repo.SetWatcherEnabled(true);

src/ViewModels/Archive.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public override async Task<bool> Sure()
5454

5555
var succ = await new Commands.Archive(_repo.FullPath, _revision, _saveFile)
5656
.Use(log)
57-
.ExecAsync()
58-
.ConfigureAwait(false);
57+
.ExecAsync();
5958

6059
log.Complete();
6160
_repo.SetWatcherEnabled(true);

src/ViewModels/AssumeUnchangedManager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public AssumeUnchangedManager(Repository repo)
1818
var collect = await new Commands.QueryAssumeUnchangedFiles(_repo.FullPath)
1919
.GetResultAsync()
2020
.ConfigureAwait(false);
21-
22-
await Dispatcher.UIThread.InvokeAsync(() => Files.AddRange(collect));
21+
Dispatcher.UIThread.Post(() => Files.AddRange(collect));
2322
});
2423
}
2524

@@ -31,8 +30,7 @@ public async Task RemoveAsync(string file)
3130

3231
await new Commands.AssumeUnchanged(_repo.FullPath, file, false)
3332
.Use(log)
34-
.ExecAsync()
35-
.ConfigureAwait(false);
33+
.ExecAsync();
3634

3735
log.Complete();
3836
Files.Remove(file);

0 commit comments

Comments
 (0)