a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[frontend/components] Fix error handling when checking for updates.

authored by

Lilian and committed by
Laura Hausmann
1e680bd3 6a6961ba

+21 -7
+21 -7
Iceshrimp.Frontend/Pages/Settings/About.razor
··· 1 1 @page "/settings/about" 2 2 @using System.Text 3 3 @using Iceshrimp.Assets.PhosphorIcons 4 - @using Iceshrimp.Frontend.Components 5 4 @using Iceshrimp.Frontend.Core.InMemoryLogger 6 5 @using Iceshrimp.Frontend.Core.Services 7 6 @using Iceshrimp.Frontend.Localization ··· 16 15 @inject InMemoryLogService LogSvc; 17 16 @inject UpdateService UpdateSvc; 18 17 @inject NavigationManager Nav; 19 - @inject GlobalComponentSvc GlobalComponentSvc; 18 + @inject ILogger<About> Logger; 20 19 21 20 <div class="body"> 22 21 <div class="version"> ··· 64 63 } 65 64 </div> 66 65 <button class="button" @onclick="@SkipWaiting">@Loc["Load new version"]</button> 67 - @if (_skipWaitingRes == CheckState.False) 66 + @if (_skipWaitingRes == CheckState.Error) 68 67 { 69 - <div>@Loc["Something went wrong, please check the logs."]</div> 68 + <div>@Loc["Something went wrong while loading the update, please check the logs."]</div> 70 69 } 71 70 } 72 71 @if (_updateAvailable == CheckState.False) 73 72 { 74 73 <div>@Loc["Already on the newest version!"]</div> 75 74 } 75 + @if (_updateAvailable == CheckState.Error) 76 + { 77 + <div>@Loc["Failed to check for updates."]</div> 78 + } 76 79 77 80 </div> 78 81 <div class="logs"> ··· 101 104 { 102 105 Unknown, 103 106 True, 104 - False 107 + False, 108 + Error 105 109 } 106 110 107 111 private async void CheckUpdate() 108 112 { 109 - await UpdateSvc.ServiceWorkerUpdate(); 113 + try 114 + { 115 + await UpdateSvc.ServiceWorkerUpdate(); 116 + } 117 + catch (Exception e) 118 + { 119 + Logger.LogError(e, "Failed to check for updates."); 120 + _updateAvailable = CheckState.Error; 121 + return; 122 + } 123 + 110 124 var res = await UpdateSvc.ServiceWorkerCheckWaiting(); 111 125 _updateAvailable = res ? CheckState.True : CheckState.False; 112 126 _newVersion = UpdateSvc.BackendVersion; ··· 116 130 private async void SkipWaiting() 117 131 { 118 132 var res = await UpdateSvc.ServiceWorkerSkipWaiting(); 119 - _skipWaitingRes = res ? CheckState.True : CheckState.False; 133 + _skipWaitingRes = res ? CheckState.True : CheckState.Error; 120 134 if (res) 121 135 { 122 136 Nav.NavigateTo("/", true);