Neighbourhood.omg.lol/Components/PicList.razor

31 lines
901 B
Text
Raw Normal View History

2024-06-07 04:25:21 +00:00
@inject IJSRuntime JS
2024-06-13 00:26:43 +00:00
@inject State State
2024-06-11 07:24:52 +00:00
@if (Editable) {
<EditPicDialog @ref="Dialog" id="EditPicModal"></EditPicDialog>
2024-06-11 07:24:52 +00:00
}
@if (pics != null) foreach (Pic pic in pics) {
<PicCard Pic="pic" Editable="Editable" Dialog="Dialog"></PicCard>
}
2024-06-11 07:24:52 +00:00
<LoadingCard id="pics-loading" icon="fa-solid fa-images"></LoadingCard>
2024-06-05 12:41:08 +00:00
@code {
[Parameter]
2024-06-11 07:24:52 +00:00
public Func<Task<List<Pic>?>> PicsFunc { get; set; }
2024-06-07 04:25:21 +00:00
[Parameter]
public bool Editable { get; set; } = false;
2024-06-11 07:24:52 +00:00
public EditPicDialog? Dialog { get; set; }
2024-06-11 07:24:52 +00:00
private List<Pic>? pics;
2024-06-11 07:24:52 +00:00
// TODO: There is a noticable rendering delay between the pics loading and the page rendering
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
if (pics == null || pics.Count == 0) pics = await PicsFunc();
await InvokeAsync(StateHasChanged);
await JS.InvokeVoidAsync("removeElementById", "pics-loading");
2024-06-11 07:24:52 +00:00
}
}