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:
@ -1,10 +1,7 @@
|
|||||||
using System.Security.Policy;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Wabbajack.DTOs;
|
|
||||||
using Wabbajack.DTOs.DownloadStates;
|
using Wabbajack.DTOs.DownloadStates;
|
||||||
using Wabbajack.DTOs.Interventions;
|
using Wabbajack.DTOs.Interventions;
|
||||||
using Wabbajack.Paths;
|
|
||||||
|
|
||||||
namespace Wabbajack.UserIntervention;
|
namespace Wabbajack.UserIntervention;
|
||||||
|
|
||||||
@ -21,13 +18,13 @@ public class ManualDownloadHandler : BrowserWindowViewModel
|
|||||||
HeaderText = $"Manual download ({md.Url.Host})";
|
HeaderText = $"Manual download ({md.Url.Host})";
|
||||||
|
|
||||||
Instructions = string.IsNullOrWhiteSpace(md.Prompt) ? $"Please download {archive.Name}" : md.Prompt;
|
Instructions = string.IsNullOrWhiteSpace(md.Prompt) ? $"Please download {archive.Name}" : md.Prompt;
|
||||||
await NavigateTo(md.Url);
|
|
||||||
|
|
||||||
|
var task = WaitForDownloadUri(token, async () =>
|
||||||
var uri = await WaitForDownloadUri(token, async () =>
|
|
||||||
{
|
{
|
||||||
await RunJavaScript("Array.from(document.getElementsByTagName(\"iframe\")).forEach(f => f.remove())");
|
await RunJavaScript("Array.from(document.getElementsByTagName(\"iframe\")).forEach(f => f.remove())");
|
||||||
});
|
});
|
||||||
|
await NavigateTo(md.Url);
|
||||||
|
var uri = await task;
|
||||||
|
|
||||||
Intervention.Finish(uri);
|
Intervention.Finish(uri);
|
||||||
}
|
}
|
||||||
|
@ -112,11 +112,13 @@ public abstract class BrowserWindowViewModel : ViewModel
|
|||||||
{
|
{
|
||||||
var source = new TaskCompletionSource<Uri>();
|
var source = new TaskCompletionSource<Uri>();
|
||||||
var referer = _browser.Source;
|
var referer = _browser.Source;
|
||||||
|
while (_browser.CoreWebView2 == null)
|
||||||
|
await Task.Delay(10, token);
|
||||||
|
|
||||||
_browser.CoreWebView2.DownloadStarting += (sender, args) =>
|
_browser.CoreWebView2.DownloadStarting += (sender, args) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
source.SetResult(new Uri(args.DownloadOperation.Uri));
|
source.SetResult(new Uri(args.DownloadOperation.Uri));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
Reference in New Issue
Block a user