Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use common samples for now #106

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion My1kWordsEe/Components/Pages/FavoritesPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
foreach (var wordPair in favorites.Words)
{
var word = wordPair.Value;
<div class="col col-12 col-sm-6">
<div class="col col-12 col-sm-6 p-1">
<Card>
<CardBody>
<CardTitle>
Expand Down
22 changes: 8 additions & 14 deletions My1kWordsEe/Components/Pages/Word.razor
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,13 @@
var commonSample = this.EnsureWordCommand.Invoke(EeWord);
if (IsLoggedIn)
{
var user = await UserAccessor.GetRequiredUserAsync(User);

Check warning on line 55 in My1kWordsEe/Components/Pages/Word.razor

View workflow job for this annotation

GitHub Actions / test

Possible null reference argument for parameter 'user' in 'Task<ApplicationUser> IdentityUserAccessor.GetRequiredUserAsync(ClaimsPrincipal user)'.
var favorites = GetFavoritesQuery.Invoke(user.Id);
await Task.WhenAll(commonSample, favorites);

if (favorites.Result.IsSuccess)
{
Favorites = favorites.Result;
var favoriteWords = favorites.Result.Value.Words;
if (favoriteWords.ContainsKey(EeWord))
{
return favoriteWords[EeWord];
}
}
}

Expand All @@ -73,7 +68,7 @@
private async Task AddToFavorites()
{
PreloadService.Show(SpinnerColor.Light, "Saving data...");
var user = await UserAccessor.GetRequiredUserAsync(User);

Check warning on line 71 in My1kWordsEe/Components/Pages/Word.razor

View workflow job for this annotation

GitHub Actions / test

Possible null reference argument for parameter 'user' in 'Task<ApplicationUser> IdentityUserAccessor.GetRequiredUserAsync(ClaimsPrincipal user)'.
await AddToFavoritesCommand.Invoke(user.Id, Value);
await OnParametersSetAsync();
PreloadService.Hide();
Expand All @@ -82,7 +77,7 @@
private async Task RemoveFromFavorites()
{
PreloadService.Show(SpinnerColor.Light, "Saving data...");
var user = await UserAccessor.GetRequiredUserAsync(User);

Check warning on line 80 in My1kWordsEe/Components/Pages/Word.razor

View workflow job for this annotation

GitHub Actions / test

Possible null reference argument for parameter 'user' in 'Task<ApplicationUser> IdentityUserAccessor.GetRequiredUserAsync(ClaimsPrincipal user)'.
await RemoveFromFavoritesCommand.Invoke(user.Id, Value.EeWord);
await OnParametersSetAsync();
PreloadService.Hide();
Expand Down Expand Up @@ -114,6 +109,8 @@
private string Error => WordMetadata.Value.Error;

private bool IsLoggedIn => User?.Identity?.IsAuthenticated ?? false;

private bool IsFavorite => IsDataLoadedOk && IsLoggedIn && Favorites.HasValue && Favorites.Value.IsSuccess && Favorites.Value.Value.Words.ContainsKey(EeWord.ToLower());
}

<script>
Expand All @@ -128,16 +125,13 @@
<h1>
@EeWord

@if (IsDataLoadedOk && IsLoggedIn)
@if (IsFavorite)
{
@if (Favorites.Value.Value.Words.ContainsKey(EeWord.ToLower()))
{
<i role="button" class="bi bi-star-fill" @onclick="RemoveFromFavorites"></i>
}
else
{
<i role="button" class="bi bi-star" @onclick="AddToFavorites"></i>
}
<i role="button" class="bi bi-star-fill" @onclick="RemoveFromFavorites"></i>
}
else
{
<i role="button" class="bi bi-star" @onclick="AddToFavorites"></i>
}

@if (IsDataLoadedOk && Value.EeAudioUrl != null)
Expand Down
6 changes: 3 additions & 3 deletions My1kWordsEe/Services/Cqs/AddSampleSentenceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public async Task<Result<SampleWord>> Invoke(SampleWord word)
}).ToArray()
};

await this.azureBlobService.SaveWordData(updatedWordData);

return Result.Success(updatedWordData);
return (await this.azureBlobService
.SaveWordData(updatedWordData))
.Bind(r => Result.Success(updatedWordData));
}

private Task<Result<Uri>> GenerateImage(Sentence sentence) =>
Expand Down
Loading