[frontend] Remove processed follow requests from list (ISH-409)
This commit is contained in:
parent
f904773faa
commit
c47fccc9b6
2 changed files with 22 additions and 5 deletions
|
@ -22,17 +22,16 @@
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter] [EditorRequired] public required FollowRequestResponse FollowRequest { get; set; }
|
[Parameter] [EditorRequired] public required FollowRequestResponse FollowRequest { get; set; }
|
||||||
|
[Parameter] [EditorRequired] public required EventCallback<string> OnDelete { get; set; }
|
||||||
private async void Accept()
|
private async void Accept()
|
||||||
{
|
{
|
||||||
// FIXME: This should be a fancy animation instead of a reload
|
|
||||||
await Api.FollowRequests.AcceptFollowRequest(FollowRequest.Id);
|
await Api.FollowRequests.AcceptFollowRequest(FollowRequest.Id);
|
||||||
NavigationManager.NavigateTo("/follow-requests");
|
await OnDelete.InvokeAsync(FollowRequest.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Reject()
|
private async void Reject()
|
||||||
{
|
{
|
||||||
// FIXME: This should be a fancy animation instead of a reloady
|
|
||||||
await Api.FollowRequests.RejectFollowRequest(FollowRequest.Id);
|
await Api.FollowRequests.RejectFollowRequest(FollowRequest.Id);
|
||||||
NavigationManager.NavigateTo("/follow-requests");
|
await OnDelete.InvokeAsync(FollowRequest.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@
|
||||||
<div class="scroller">
|
<div class="scroller">
|
||||||
@foreach (var el in FollowRequests)
|
@foreach (var el in FollowRequests)
|
||||||
{
|
{
|
||||||
<FollowRequestEntry FollowRequest="el"/>
|
<FollowRequestEntry FollowRequest="el" OnDelete="Delete"/>
|
||||||
}
|
}
|
||||||
<ScrollEnd IntersectionChange="LoadMore" ManualLoad="LoadMore"/>
|
<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()
|
private async Task LoadMore()
|
||||||
{
|
{
|
||||||
var pq = new PaginationQuery { MaxId = _minId, Limit = 20 };
|
var pq = new PaginationQuery { MaxId = _minId, Limit = 20 };
|
||||||
|
|
Loading…
Add table
Reference in a new issue