[frontend] Remove processed follow requests from list (ISH-409)

This commit is contained in:
Lilian 2024-07-23 18:33:45 +02:00
parent f904773faa
commit c47fccc9b6
No known key found for this signature in database
2 changed files with 22 additions and 5 deletions

View file

@ -22,17 +22,16 @@
@code {
[Parameter] [EditorRequired] public required FollowRequestResponse FollowRequest { get; set; }
[Parameter] [EditorRequired] public required EventCallback<string> OnDelete { get; set; }
private async void Accept()
{
// FIXME: This should be a fancy animation instead of a reload
await Api.FollowRequests.AcceptFollowRequest(FollowRequest.Id);
NavigationManager.NavigateTo("/follow-requests");
await OnDelete.InvokeAsync(FollowRequest.Id);
}
private async void Reject()
{
// FIXME: This should be a fancy animation instead of a reloady
await Api.FollowRequests.RejectFollowRequest(FollowRequest.Id);
NavigationManager.NavigateTo("/follow-requests");
await OnDelete.InvokeAsync(FollowRequest.Id);
}
}

View file

@ -12,7 +12,7 @@
<div class="scroller">
@foreach (var el in FollowRequests)
{
<FollowRequestEntry FollowRequest="el"/>
<FollowRequestEntry FollowRequest="el" OnDelete="Delete"/>
}
<ScrollEnd IntersectionChange="LoadMore" ManualLoad="LoadMore"/>
@ -63,6 +63,24 @@
}
}
private void Delete(string id)
{
var i = FollowRequests.FindIndex(p => p.Id == id);
if (FollowRequests.Count == 1)
{
_init = LoadState.Emtpy;
StateHasChanged();
FollowRequests.RemoveAt(i);
_minId = null;
}
else
{
if (i == FollowRequests.Count - 1) _minId = FollowRequests[^2].Id;
if (i >= 0) FollowRequests.RemoveAt(i);
StateHasChanged();
}
}
private async Task LoadMore()
{
var pq = new PaginationQuery { MaxId = _minId, Limit = 20 };