Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsPilgaard committed Jul 7, 2024
1 parent 4464450 commit 0728547
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/web/Jordnaer/Features/Chat/UserAutoComplete.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@
@using Jordnaer.Models
@using Jordnaer.Shared
@using MudBlazor

@attribute [Authorize]

@inject IUserSearchService UserSearchService
@inject ISnackbar Snackbar
@inject CurrentUser CurrentUser

@if (CurrentUser.Id is null)
{
return;
}

<MudAutocomplete T="UserSlim"
@ref="_autocomplete"
Expand All @@ -21,10 +30,10 @@
MinCharacters="2">

<ItemTemplate Context="user">
<MudListItem OnClick="@(async() => await UserSelected(user))" Dense="true" Class="chat-selector" T="RenderFragment">
<MudListItem OnClick="@(async() => await UserSelected(user))" Dense="true" Class="chat-selector-autocomplete" T="RenderFragment">

<MudAvatar Size="Size.Large" Class="mr-3">
<MudImage Src="@user?.ProfilePictureUrl" loading="lazy" Alt="Avatar" />
<MudImage Src="@user.ProfilePictureUrl" loading="lazy" Alt="Avatar" />
</MudAvatar>
<MudText>@user.DisplayName</MudText>

Expand All @@ -50,9 +59,6 @@
[Parameter]
public EventCallback<IEnumerable<UserSlim>> SelectedUserChanged { get; set; }

[Parameter]
public required string CurrentUserId { get; set; }

private MudAutocomplete<UserSlim> _autocomplete = null!;

private async Task<IEnumerable<UserSlim>> SearchForUsers(string searchString, CancellationToken cancellationToken)
Expand All @@ -62,7 +68,7 @@
return Enumerable.Empty<UserSlim>();
}

return await UserSearchService.GetUsersByNameAsync(CurrentUserId, searchString, cancellationToken);
return await UserSearchService.GetUsersByNameAsync(CurrentUser.Id!, searchString, cancellationToken);
}

private async Task UserSelected(UserSlim user)
Expand Down

0 comments on commit 0728547

Please sign in to comment.