Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5d50916

Browse files
committedSep 10, 2021
Fixes #24
1 parent 22c599b commit 5d50916

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed
 

‎LinkDotNet.Blog.IntegrationTests/Web/Pages/BlogPostPageTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public async Task ShouldSubtractLikeOnEvent()
4646
await Repository.StoreAsync(publishedPost);
4747
using var ctx = new TestContext();
4848
var localStorage = new Mock<ILocalStorageService>();
49-
localStorage.Setup(l => l.ContainKeyAsync("hasLiked", default)).ReturnsAsync(true);
50-
localStorage.Setup(l => l.GetItemAsync<bool>("hasLiked", default)).ReturnsAsync(true);
49+
var hasLikedStorage = $"hasLiked/{publishedPost.Id}";
50+
localStorage.Setup(l => l.ContainKeyAsync(hasLikedStorage, default)).ReturnsAsync(true);
51+
localStorage.Setup(l => l.GetItemAsync<bool>(hasLikedStorage, default)).ReturnsAsync(true);
5152
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
5253
RegisterComponents(ctx, localStorage.Object);
5354
ctx.AddTestAuthorization().SetAuthorized("s");

‎LinkDotNet.Blog.Web/Shared/Like.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242

4343
HasLiked = !HasLiked;
4444
await OnBlogPostLiked.InvokeAsync(HasLiked);
45-
await localStorage.SetItemAsync("hasLiked", HasLiked);
45+
await localStorage.SetItemAsync($"hasLiked/{BlogPost.Id}", HasLiked);
4646
}
4747

4848
private async Task<bool> GetHasLiked()
4949
{
50-
if (await localStorage.ContainKeyAsync("hasLiked"))
50+
if (await localStorage.ContainKeyAsync($"hasLiked/{BlogPost.Id}"))
5151
{
52-
return await localStorage.GetItemAsync<bool>("hasLiked");
52+
return await localStorage.GetItemAsync<bool>($"hasLiked/{BlogPost.Id}");
5353
}
5454

5555
return false;

0 commit comments

Comments
 (0)
Please sign in to comment.