From ae8cea263fe79809d2c8fa95907e98e7de7943b6 Mon Sep 17 00:00:00 2001 From: Chanan Braunstein Date: Thu, 6 Dec 2018 09:57:44 -0700 Subject: [PATCH] v0.7.1 --- README.md | 5 ----- src/BlazorDB/BlazorDB.csproj | 2 +- src/BlazorDB/StorageContext.cs | 3 +++ src/Sample/Pages/TodoItemForm.cshtml | 17 ++++------------- src/Sample/Pages/Todos.cshtml | 3 +-- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index e233c12..5e72b0f 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,6 @@ protected async override Task OnInitAsync() } ``` -## Note about the sample project - -The Todo page does not work fully. The TodoForm that allows you to edit an item or add a new item is not working correctly. The OnInitAsync in the -child component is not firing. However, since BlazorDB itself it working, I decided to publish the version and figure out the Sample app afterwards. - ## Docs ### Install diff --git a/src/BlazorDB/BlazorDB.csproj b/src/BlazorDB/BlazorDB.csproj index 01a1673..67900db 100644 --- a/src/BlazorDB/BlazorDB.csproj +++ b/src/BlazorDB/BlazorDB.csproj @@ -7,7 +7,7 @@ false 7.3 BlazorDB - 0.7.0 + 0.7.1 Chanan Braunstein Blazor localStorage Database In memory, persisted to localstorage, database for .net Blazor browser framework diff --git a/src/BlazorDB/StorageContext.cs b/src/BlazorDB/StorageContext.cs index 52b31f4..a007362 100644 --- a/src/BlazorDB/StorageContext.cs +++ b/src/BlazorDB/StorageContext.cs @@ -6,6 +6,7 @@ namespace BlazorDB public class StorageContext : IStorageContext { protected IStorageManager StorageManager { get; set; } + private bool _initalized = false; public async Task LogToConsole() { await Logger.StartContextType(GetType(), false); @@ -26,6 +27,8 @@ public Task SaveChanges() public Task Initialize() { + if (_initalized) return Task.CompletedTask; + _initalized = true; return StorageManager.LoadContextFromLocalStorage(this); } } diff --git a/src/Sample/Pages/TodoItemForm.cshtml b/src/Sample/Pages/TodoItemForm.cshtml index 76c6b36..08f3eec 100644 --- a/src/Sample/Pages/TodoItemForm.cshtml +++ b/src/Sample/Pages/TodoItemForm.cshtml @@ -21,7 +21,7 @@
- +
@@ -33,23 +33,14 @@ protected async override Task OnInitAsync() { - Console.WriteLine("OnInitAsync"); - await Context.Initialize(); + if (Context.Todos == null) await Context.Initialize(); if (SelectedId == 0) Todo = new TodoItem(); - else - { - SetTodo(); - } + else SetTodo(); } protected async override Task OnParametersSetAsync() { - Console.WriteLine("OnParametersSetAsync"); - if (Context.Todos == null) - { - Console.WriteLine("OnParametersSetAsync - init"); - await Context.Initialize(); - } + if (Context.Todos == null) await Context.Initialize(); SetTodo(); } diff --git a/src/Sample/Pages/Todos.cshtml b/src/Sample/Pages/Todos.cshtml index c408cc5..60cf6ce 100644 --- a/src/Sample/Pages/Todos.cshtml +++ b/src/Sample/Pages/Todos.cshtml @@ -26,7 +26,7 @@

Selected Item

- + @functions { string Filter { get; set; } @@ -64,7 +64,6 @@ void onClickItem(int i) { - Console.WriteLine("Todos onClickItem: {0}", i); SelectedId = i; StateHasChanged(); }