diff --git a/JournalApp/Components/Pages/Index.razor b/JournalApp/Components/Pages/Index.razor index b26354b..4de5083 100644 --- a/JournalApp/Components/Pages/Index.razor +++ b/JournalApp/Components/Pages/Index.razor @@ -116,15 +116,16 @@ AppDbContext db; bool _disposed; Day _day; - DateTimeOffset _stoppedDate; + bool _leaving; IDisposable locationChangingRegistration; + DateTimeOffset _stoppedDate; [Parameter] public string OpenToDateString { get; set; } protected override async Task OnInitializedAsync() { - logger.LogDebug("Initializing asynchronously"); + logger.LogDebug("Initializing asynchronously"); db = await DbFactory.CreateDbContextAsync(); await base.OnInitializedAsync(); @@ -294,6 +295,7 @@ ValueTask OnLocationChanging(LocationChangingContext e) { + _leaving = true; SavePage(); return ValueTask.CompletedTask; } @@ -322,4 +324,7 @@ locationChangingRegistration?.Dispose(); db?.Dispose(); } + + // https://github.com/dotnet/aspnetcore/issues/53863 + protected override bool ShouldRender() => !_leaving; } diff --git a/JournalApp/Components/Pages/ManageCategoriesPage.razor b/JournalApp/Components/Pages/ManageCategoriesPage.razor index e25a466..878b7fc 100644 --- a/JournalApp/Components/Pages/ManageCategoriesPage.razor +++ b/JournalApp/Components/Pages/ManageCategoriesPage.razor @@ -44,6 +44,7 @@ @code { AppDbContext db; + bool _leaving; [Parameter] public string Group { get; set; } @@ -131,6 +132,7 @@ void Submit() { logger.LogInformation("Going to index"); + _leaving = true; NavigationManager.NavigateTo("/", false, true); } @@ -140,4 +142,6 @@ db?.Dispose(); Snackbar.Clear(); } + + protected override bool ShouldRender() => !_leaving; } \ No newline at end of file diff --git a/JournalApp/Components/Pages/MoodGrid/MoodGridPage.razor b/JournalApp/Components/Pages/MoodGrid/MoodGridPage.razor index 272cf28..8674ab3 100644 --- a/JournalApp/Components/Pages/MoodGrid/MoodGridPage.razor +++ b/JournalApp/Components/Pages/MoodGrid/MoodGridPage.razor @@ -37,9 +37,10 @@ @code { - MoodGridSwitcher _switcher; - DataPointCategory _moodCategory; GridYear? _gridYear = null; + bool _leaving; + DataPointCategory _moodCategory; + MoodGridSwitcher _switcher; [Parameter] public string OpenToDateString { get; set; } @@ -217,6 +218,7 @@ void Close() { logger.LogInformation("Going to index"); + _leaving = true; NavigationManager.NavigateTo("/", false, true); } @@ -226,6 +228,7 @@ return; Snackbar.TeachingTipActionTaken("click_mood_grid_day"); + _leaving = true; NavigationManager.NavigateTo($"/{date:yyyyMMdd}", false, true); } @@ -234,4 +237,6 @@ KeyEventService.Exited(); Snackbar.Clear(); } + + protected override bool ShouldRender() => !_leaving; } \ No newline at end of file diff --git a/JournalApp/Components/Pages/SafetyPlanning/SafetyPlanPage.razor b/JournalApp/Components/Pages/SafetyPlanning/SafetyPlanPage.razor index bb6f33e..4f46bc8 100644 --- a/JournalApp/Components/Pages/SafetyPlanning/SafetyPlanPage.razor +++ b/JournalApp/Components/Pages/SafetyPlanning/SafetyPlanPage.razor @@ -60,6 +60,8 @@ @code { + bool _leaving; + public SafetyPlan Plan { get; set; } protected override void OnInitialized() @@ -75,6 +77,7 @@ void Submit() { logger.LogInformation("Going to index"); + _leaving = true; NavigationManager.NavigateTo("/", false, true); } @@ -88,4 +91,6 @@ else Preferences.Default.SetJson("safety_plan", Plan); } + + protected override bool ShouldRender() => !_leaving; } \ No newline at end of file diff --git a/JournalApp/Components/Pages/SettingsPage.razor b/JournalApp/Components/Pages/SettingsPage.razor index 8df71d3..9c557d9 100644 --- a/JournalApp/Components/Pages/SettingsPage.razor +++ b/JournalApp/Components/Pages/SettingsPage.razor @@ -8,7 +8,7 @@ @inject IDialogService DialogService @inject AppThemeService AppThemeService -@if (_isBusy) +@if (_busy) { @* TODO: Replace with separate page so we can change state of inline fields and have it updated properly in settings *@