diff --git a/src/Angor/Client/Pages/Settings.razor b/src/Angor/Client/Pages/Settings.razor index c4c16d56..47a6e23c 100644 --- a/src/Angor/Client/Pages/Settings.razor +++ b/src/Angor/Client/Pages/Settings.razor @@ -51,7 +51,7 @@ { @indexer.Url - @(indexer.IsOnline ? "Online" : "Offline") + @indexer.Status.ToString() @if (indexer.IsPrimary) { @@ -96,7 +96,7 @@ { @relay.Url - @(relay.IsOnline ? "Online" : "Offline") + @relay.Status.ToString() @if (relay.IsPrimary) { @@ -229,7 +229,7 @@ if (res.IsPrimary && settingsInfo.Indexers.Any()) { - var next = settingsInfo.Indexers.OrderBy(a => a.IsOnline).First(); + var next = settingsInfo.Indexers.OrderBy(a => a.Status).First(); next.IsPrimary = true; } @@ -247,7 +247,7 @@ if (res.IsPrimary && settingsInfo.Relays.Any()) { - var next = settingsInfo.Relays.OrderBy(a => a.IsOnline).First(); + var next = settingsInfo.Relays.OrderBy(a => a.Status).First(); next.IsPrimary = true; } diff --git a/src/Angor/Client/Services/NetworkService.cs b/src/Angor/Client/Services/NetworkService.cs index 1e24dea3..5d177472 100644 --- a/src/Angor/Client/Services/NetworkService.cs +++ b/src/Angor/Client/Services/NetworkService.cs @@ -38,7 +38,7 @@ public async Task CheckServices(bool force = false) if (response.IsSuccessStatusCode) { - indexerUrl.IsOnline = true; + indexerUrl.Status = UrlStatus.Online; } else { @@ -47,7 +47,7 @@ public async Task CheckServices(bool force = false) } catch (Exception ex) { - indexerUrl.IsOnline = false; + indexerUrl.Status = UrlStatus.Offline; _logger.LogError(ex, $"Failed to check indexer status url = {indexerUrl.Url}"); } } @@ -67,7 +67,7 @@ public async Task CheckServices(bool force = false) if (response.IsSuccessStatusCode) { - relayUrl.IsOnline = true; + relayUrl.Status = UrlStatus.Online; } else { @@ -76,7 +76,7 @@ public async Task CheckServices(bool force = false) } catch (Exception ex) { - relayUrl.IsOnline = false; + relayUrl.Status = UrlStatus.Offline; _logger.LogError(ex, $"Failed to check relay status url = {relayUrl.Url}"); } } @@ -120,7 +120,7 @@ public void CheckAndHandleError(HttpResponseMessage httpResponseMessage) if (host != null) { - host.IsOnline = false; + host.Status = UrlStatus.Offline; _networkStorage.SetSettings(settings); } } diff --git a/src/Angor/Shared/Models/SettingsUrl.cs b/src/Angor/Shared/Models/SettingsUrl.cs index 72e3b095..0b0d7769 100644 --- a/src/Angor/Shared/Models/SettingsUrl.cs +++ b/src/Angor/Shared/Models/SettingsUrl.cs @@ -13,8 +13,15 @@ public class SettingsUrl public bool IsPrimary { get; set; } - public bool IsOnline { get; set; } + public UrlStatus Status { get; set; } public DateTime LastCheck { get; set; } } +public enum UrlStatus +{ + Offline, + NotReady, + Online +} +