47 lines
1.4 KiB
Text
47 lines
1.4 KiB
Text
@implements IDisposable
|
|
@inject IJSRuntime JS
|
|
@inject State State
|
|
|
|
@if (Editable) {
|
|
<EditStatusDialog @ref="Dialog" id="EditStatusModal"></EditStatusDialog>
|
|
}
|
|
|
|
@if(statuses != null) foreach(Status status in statuses) {
|
|
<StatusCard Status="@status" Editable="Editable" Dialog="Dialog"></StatusCard>
|
|
}
|
|
|
|
<LoadingCard id="statusLoading" icon="fa-solid fa-message-smile"></LoadingCard>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public Func<bool, Task<List<Status>?>> StatusFunc { get; set; }
|
|
[Parameter]
|
|
public bool Editable { get; set; } = false;
|
|
|
|
public EditStatusDialog? Dialog { get; set; }
|
|
|
|
private List<Status>? statuses;
|
|
|
|
protected override async Task OnInitializedAsync() {
|
|
await base.OnInitializedAsync();
|
|
if (statuses == null || statuses.Count == 0) statuses = await StatusFunc(false);
|
|
State.PropertyChanged += StateChanged;
|
|
State.CanRefresh = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
await JS.InvokeVoidAsync("removeElementById", "statusLoading");
|
|
}
|
|
|
|
private async void StateChanged(object? sender, PropertyChangedEventArgs e) {
|
|
if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) {
|
|
using (State.GetRefreshToken()) {
|
|
statuses = await StatusFunc(true);
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Dispose() {
|
|
State.PropertyChanged -= StateChanged;
|
|
State.CanRefresh = false;
|
|
}
|
|
}
|