Skip to content

Commit 2a0f9f4

Browse files
committed
fix: onSure is not asigned to Views.Confirm.OnSure
Signed-off-by: leo <[email protected]>
1 parent 4076582 commit 2a0f9f4

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

src/App.axaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,19 @@ 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+
151159
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } owner })
152160
{
153161
var confirm = new Views.Confirm();
154162
confirm.Message.Text = message;
163+
confirm.OnSure = onSure;
155164
return await confirm.ShowDialog<bool>(owner);
156165
}
157166

src/ViewModels/Checkout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public override async Task<bool> Sure()
4545
var succ = false;
4646
var needPopStash = false;
4747

48-
var confirmed = await _repo.ConfirmCheckoutBranchAsync().ConfigureAwait(false);
48+
var confirmed = await _repo.ConfirmCheckoutBranchAsync();
4949
if (!confirmed)
5050
{
5151
_repo.SetWatcherEnabled(true);

src/ViewModels/CheckoutAndFastForward.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public override async Task<bool> Sure()
5050
var succ = false;
5151
var needPopStash = false;
5252

53-
var confirmed = await _repo.ConfirmCheckoutBranchAsync().ConfigureAwait(false);
53+
var confirmed = await _repo.ConfirmCheckoutBranchAsync();
5454
if (!confirmed)
5555
{
5656
_repo.SetWatcherEnabled(true);

src/ViewModels/CheckoutCommit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public override async Task<bool> Sure()
4545
bool succ;
4646
var needPop = false;
4747

48-
var confirmed = await _repo.ConfirmCheckoutBranchAsync().ConfigureAwait(false);
48+
var confirmed = await _repo.ConfirmCheckoutBranchAsync();
4949
if (!confirmed)
5050
{
5151
_repo.SetWatcherEnabled(true);

src/ViewModels/LauncherPage.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,28 +105,19 @@ public async void ProcessPopup()
105105
return;
106106

107107
dump.InProgress = true;
108-
var task = dump.Sure();
109-
var finished = false;
110-
if (task != null)
108+
109+
try
111110
{
112-
try
113-
{
114-
finished = await task;
115-
}
116-
catch (Exception e)
117-
{
118-
App.LogException(e);
119-
}
120-
121-
dump.InProgress = false;
111+
var finished = await dump.Sure();
122112
if (finished)
123113
Popup = null;
124114
}
125-
else
115+
catch (Exception e)
126116
{
127-
dump.InProgress = false;
128-
Popup = null;
117+
App.LogException(e);
129118
}
119+
120+
dump.InProgress = false;
130121
}
131122
}
132123

0 commit comments

Comments
 (0)