mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix manual downloads sometimes launching in browser
This commit is contained in:
parent
77f6b8c9cb
commit
ae7402be58
@ -1,10 +1,7 @@
|
||||
using System.Security.Policy;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.DTOs;
|
||||
using Wabbajack.DTOs.DownloadStates;
|
||||
using Wabbajack.DTOs.Interventions;
|
||||
using Wabbajack.Paths;
|
||||
|
||||
namespace Wabbajack.UserIntervention;
|
||||
|
||||
@ -17,18 +14,18 @@ public class ManualDownloadHandler : BrowserWindowViewModel
|
||||
//await WaitForReady();
|
||||
var archive = Intervention.Archive;
|
||||
var md = Intervention.Archive.State as Manual;
|
||||
|
||||
|
||||
HeaderText = $"Manual download ({md.Url.Host})";
|
||||
|
||||
|
||||
Instructions = string.IsNullOrWhiteSpace(md.Prompt) ? $"Please download {archive.Name}" : md.Prompt;
|
||||
await NavigateTo(md.Url);
|
||||
|
||||
|
||||
var uri = await WaitForDownloadUri(token, async () =>
|
||||
var task = WaitForDownloadUri(token, async () =>
|
||||
{
|
||||
await RunJavaScript("Array.from(document.getElementsByTagName(\"iframe\")).forEach(f => f.remove())");
|
||||
});
|
||||
|
||||
await NavigateTo(md.Url);
|
||||
var uri = await task;
|
||||
|
||||
Intervention.Finish(uri);
|
||||
}
|
||||
}
|
@ -112,11 +112,13 @@ public abstract class BrowserWindowViewModel : ViewModel
|
||||
{
|
||||
var source = new TaskCompletionSource<Uri>();
|
||||
var referer = _browser.Source;
|
||||
while (_browser.CoreWebView2 == null)
|
||||
await Task.Delay(10, token);
|
||||
|
||||
_browser.CoreWebView2.DownloadStarting += (sender, args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
source.SetResult(new Uri(args.DownloadOperation.Uri));
|
||||
}
|
||||
catch (Exception)
|
||||
|
Loading…
Reference in New Issue
Block a user