diff --git a/Iceshrimp.Frontend/Components/FollowRequestEntry.razor b/Iceshrimp.Frontend/Components/FollowRequestEntry.razor new file mode 100644 index 00000000..b1f00499 --- /dev/null +++ b/Iceshrimp.Frontend/Components/FollowRequestEntry.razor @@ -0,0 +1,38 @@ +@using Iceshrimp.Frontend.Localization +@using Iceshrimp.Shared.Schemas.Web +@using Microsoft.Extensions.Localization +@using Iceshrimp.Assets.PhosphorIcons +@using Iceshrimp.Frontend.Core.Services +@inject IStringLocalizer Loc; +@inject ApiService Api; +@inject NavigationManager NavigationManager; + + +
+ +
+ + +
+
+ +@code { + [Parameter] [EditorRequired] public required FollowRequestResponse FollowRequest { 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"); + } + + 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"); + } +} \ No newline at end of file diff --git a/Iceshrimp.Frontend/Components/FollowRequestEntry.razor.css b/Iceshrimp.Frontend/Components/FollowRequestEntry.razor.css new file mode 100644 index 00000000..c07ae228 --- /dev/null +++ b/Iceshrimp.Frontend/Components/FollowRequestEntry.razor.css @@ -0,0 +1,25 @@ +.follow-request-card { + display: flex; + align-items: center; + background-color: var(--foreground-color); + border-radius: 1rem; + justify-content: space-between; + max-width: 50rem; + width: 100%; + margin-bottom: 1rem; +} + +.buttons { + display: flex; +} + +.btn { + width: 4rem; + height: 4rem; +} + +::deep { + .profile-card { + margin-top: 0 !important; + } +} \ No newline at end of file diff --git a/Iceshrimp.Frontend/Components/FollowRequestList.razor b/Iceshrimp.Frontend/Components/FollowRequestList.razor new file mode 100644 index 00000000..36cac51c --- /dev/null +++ b/Iceshrimp.Frontend/Components/FollowRequestList.razor @@ -0,0 +1,93 @@ +@using Iceshrimp.Frontend.Core.Miscellaneous +@using Iceshrimp.Frontend.Core.Services +@using Iceshrimp.Frontend.Localization +@using Iceshrimp.Shared.Schemas.Web +@using Microsoft.Extensions.Localization +@inject ApiService Api; +@inject IStringLocalizer Loc; + +@if (_init == LoadState.Ready) +{ +
+ @foreach (var el in FollowRequests) + { + + } + + +
+} +@if (_init == LoadState.Loading) +{ +
Loading!
+} +@if (_init == LoadState.Emtpy) +{ + @Loc["All done!"] +} + +@code { + private List FollowRequests { get; set; } = []; + private LoadState _init; + private string? _minId; + + protected override async Task OnInitializedAsync() + { + await Init(); + } + + private async Task Init() + { + try + { + var pq = new PaginationQuery { Limit = 20 }; + FollowRequests = await Api.FollowRequests.GetFollowRequests(pq); + if (FollowRequests.Count == 0) + { + _init = LoadState.Emtpy; + return; + } + _minId = FollowRequests.Last().Id; + _init = LoadState.Ready; + } + catch (ApiException) + { + _init = LoadState.Error; + } + catch (HttpRequestException) + { + _init = LoadState.Error; + Console.WriteLine("Network error"); + } + } + + private async Task LoadMore() + { + var pq = new PaginationQuery { MaxId = _minId, Limit = 20 }; + var res = await Api.FollowRequests.GetFollowRequests(pq); + if (res.Count > 0) + { + FollowRequests.AddRange(res); + _minId = res.Last().Id; + StateHasChanged(); + } + } + + protected override async Task OnParametersSetAsync() + { + _init = LoadState.Loading; + _minId = null; + FollowRequests = []; + StateHasChanged(); + await Init(); + StateHasChanged(); + } + + private enum LoadState + { + Loading, + Ready, + Emtpy, + Error + } +} \ No newline at end of file diff --git a/Iceshrimp.Frontend/Components/FollowRequestList.razor.css b/Iceshrimp.Frontend/Components/FollowRequestList.razor.css new file mode 100644 index 00000000..ac67463e --- /dev/null +++ b/Iceshrimp.Frontend/Components/FollowRequestList.razor.css @@ -0,0 +1,8 @@ +.scroller { + display: flex; + align-items: center; + flex-direction: column; + width: 100%; + overflow-x: scroll; + padding: 0.5rem; +} \ No newline at end of file diff --git a/Iceshrimp.Frontend/Pages/FollowRequestsPage.razor b/Iceshrimp.Frontend/Pages/FollowRequestsPage.razor new file mode 100644 index 00000000..ab78933c --- /dev/null +++ b/Iceshrimp.Frontend/Pages/FollowRequestsPage.razor @@ -0,0 +1,6 @@ +@page "/follow-requests" +@using Iceshrimp.Frontend.Components + +@code { + +} \ No newline at end of file