From c47fccc9b6fda8e80487a063b828fd0b6cfd6929 Mon Sep 17 00:00:00 2001 From: Lilian Date: Tue, 23 Jul 2024 18:33:45 +0200 Subject: [PATCH] [frontend] Remove processed follow requests from list (ISH-409) --- .../Components/FollowRequestEntry.razor | 7 +++---- .../Components/FollowRequestList.razor | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Iceshrimp.Frontend/Components/FollowRequestEntry.razor b/Iceshrimp.Frontend/Components/FollowRequestEntry.razor index 8d0895a1..c9cacbb4 100644 --- a/Iceshrimp.Frontend/Components/FollowRequestEntry.razor +++ b/Iceshrimp.Frontend/Components/FollowRequestEntry.razor @@ -22,17 +22,16 @@ @code { [Parameter] [EditorRequired] public required FollowRequestResponse FollowRequest { get; set; } + [Parameter] [EditorRequired] public required EventCallback 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); } } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Components/FollowRequestList.razor b/Iceshrimp.Frontend/Components/FollowRequestList.razor index 9ffb4b97..fa26014e 100644 --- a/Iceshrimp.Frontend/Components/FollowRequestList.razor +++ b/Iceshrimp.Frontend/Components/FollowRequestList.razor @@ -12,7 +12,7 @@
@foreach (var el in FollowRequests) { - + } @@ -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 };