mirror of
https://gitlab.com/2009scape/Saradomin-Launcher.git
synced 2026-08-01 14:19:14 -06:00
Add logic for detecting a blocked website
This commit is contained in:
parent
ec6d05f098
commit
78bc9e4f61
2 changed files with 14 additions and 5 deletions
|
|
@ -106,7 +106,6 @@ namespace Saradomin.Infrastructure.Services
|
|||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
NotificationBox.DisplayNotification("Error!", $"Plugin service unavailable: {e.Message}");
|
||||
return new List<PluginInfo>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,13 +70,20 @@ namespace Saradomin.ViewModel.Windows
|
|||
await ExecuteLaunchSequence();
|
||||
}
|
||||
|
||||
private HtmlNode ConnectionErrorMessage(HtmlDocument doc, string msg)
|
||||
{
|
||||
var failMessage = "<html><body><h3>Not Available<h3><br/>This content is unavailable, likely due to a ";
|
||||
doc.LoadHtml(failMessage + msg + "</body></html>");
|
||||
return doc.DocumentNode;
|
||||
}
|
||||
|
||||
public async void MainViewLoaded(MainViewLoadedMessage _)
|
||||
{
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
HtmlNode node;
|
||||
var doc = new HtmlDocument();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var response =
|
||||
|
|
@ -86,10 +93,13 @@ namespace Saradomin.ViewModel.Windows
|
|||
}
|
||||
catch (HttpRequestException)
|
||||
{
|
||||
doc.LoadHtml("<html><h3>Not Available<h3><br/><body>This content is unavailable, likely due to a lack of an internet connection.</body></html>");
|
||||
node = doc.DocumentNode;
|
||||
node = ConnectionErrorMessage(doc, "lack of an internet connection.");
|
||||
}
|
||||
if (node == null)
|
||||
{
|
||||
// If 2009scape is blocked
|
||||
node = ConnectionErrorMessage(doc, "blocked internet connection. The stable server should still work.");
|
||||
}
|
||||
|
||||
var renderer = new HtmlRenderer(node);
|
||||
HtmlInlines = renderer.Render();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue