From 9ebb782d1f304f7619708c8626b43df1b756aeed Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Thu, 11 Apr 2024 13:03:44 +0200 Subject: [PATCH] Only record once --- .../Features/ShowBlogPost/ShowBlogPostPage.razor | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/LinkDotNet.Blog.Web/Features/ShowBlogPost/ShowBlogPostPage.razor b/src/LinkDotNet.Blog.Web/Features/ShowBlogPost/ShowBlogPostPage.razor index 037b9a07..caff8427 100644 --- a/src/LinkDotNet.Blog.Web/Features/ShowBlogPost/ShowBlogPostPage.razor +++ b/src/LinkDotNet.Blog.Web/Features/ShowBlogPost/ShowBlogPostPage.razor @@ -80,6 +80,7 @@ else } @code { + private string lastBlogPostId = null; [Parameter] public string BlogPostId { get; set; } @@ -96,9 +97,15 @@ else protected override async Task OnParametersSetAsync() { isLoading = true; - BlogPost = await BlogPostRepository.GetByIdAsync(BlogPostId); - isLoading = false; - _ = UserRecordService.StoreUserRecordAsync(); + BlogPost = await BlogPostRepository.GetByIdAsync(BlogPostId); + isLoading = false; + + if (lastBlogPostId != BlogPostId) + { + _ = UserRecordService.StoreUserRecordAsync(); + } + + lastBlogPostId = BlogPostId; } protected override async Task OnAfterRenderAsync(bool firstRender)