Skip to content

Commit 306b1c9

Browse files
authored
Merge pull request #1038 from Sidekick-Poe/feature/initialization
Improved initialization process (mainly for docker versions)
2 parents 5a266c0 + 03906db commit 306b1c9

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

src/Sidekick.Common.Ui/Main.razor

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using Microsoft.Extensions.Options
2+
@using Sidekick.Common.Platform
23

34
<AppWrapper>
45
<Router AppAssembly="@typeof(Main).Assembly" AdditionalAssemblies="Configuration.Value.Modules">
@@ -24,3 +25,21 @@
2425
</AppWrapper>
2526

2627
@inject IOptions<SidekickConfiguration> Configuration
28+
@inject IApplicationService ApplicationService
29+
@inject NavigationManager NavigationManager
30+
31+
@code {
32+
protected override async Task OnInitializedAsync()
33+
{
34+
if (!ApplicationService.HasInitialized)
35+
{
36+
var path = new Uri(NavigationManager.Uri).AbsolutePath;
37+
if (path != "/" && path != "/update" && path != "/setup" && path != "/initialize")
38+
{
39+
NavigationManager.NavigateTo("/");
40+
}
41+
}
42+
43+
await base.OnInitializedAsync();
44+
}
45+
}

src/Sidekick.Common/Platform/IApplicationService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public interface IApplicationService : IInitializableService
2323
/// Shutdown the application.
2424
/// </summary>
2525
void Shutdown();
26+
27+
/// <summary>
28+
/// Gets or sets a value indicating whether the application has initialized.
29+
/// </summary>
30+
bool HasInitialized { get; set; }
2631
}

src/Sidekick.Modules.General/Initialization/Initialization.razor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public async Task Handle()
104104
// If we have a successful initialization, we delay for half a second to show the
105105
// "Ready" label on the UI before closing the view
106106
completed = Count;
107+
ApplicationService.HasInitialized = true;
107108

108109
await ReportProgress();
109110
await Task.Delay(200);

src/Sidekick.PhotinoBlazor/Services/PhotinoBlazorApplicationService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,7 @@ public void Dispose()
120120
uiLanguageProvider.OnLanguageChanged -= OnLanguageChanged;
121121
Icon?.Dispose();
122122
}
123+
124+
/// <inheritdoc />
125+
public bool HasInitialized { get; set; }
123126
}

src/Sidekick.Web/Services/WebApplicationService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ public void Shutdown()
1515
{
1616
Environment.Exit(0);
1717
}
18+
19+
/// <inheritdoc />
20+
public bool HasInitialized { get; set; }
1821
}

src/Sidekick.Wpf/Services/WpfApplicationService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,7 @@ public void Dispose()
111111
uiLanguageProvider.OnLanguageChanged -= OnLanguageChanged;
112112
Icon?.Dispose();
113113
}
114+
115+
/// <inheritdoc />
116+
public bool HasInitialized { get; set; }
114117
}

0 commit comments

Comments
 (0)