Merge branch 'blockedFix' into 'master'

Add logic for detecting a blocked website

See merge request 2009scape/Saradomin-Launcher!57
This commit is contained in:
Ceikry 2024-12-07 18:19:24 +00:00
commit e88ac062d1
2 changed files with 14 additions and 5 deletions

View file

@ -106,7 +106,6 @@ namespace Saradomin.Infrastructure.Services
}
catch (HttpRequestException e)
{
NotificationBox.DisplayNotification("Error!", $"Plugin service unavailable: {e.Message}");
return new List<PluginInfo>();
}
}

View file

@ -70,6 +70,13 @@ 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())
@ -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();
}