[frontend] Add notification panel to appropriate places

This commit is contained in:
Lilian 2024-06-28 21:35:39 +02:00 committed by Laura Hausmann
parent da124c5c98
commit ffe56307f3
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
6 changed files with 35 additions and 6 deletions

View file

@ -9,6 +9,7 @@
{
<NotificationComponent NotificationResponse="el" @key="el.Id"/>
}
<ScrollEnd ManualLoad="LoadMore" IntersectionChange="LoadMore"></ScrollEnd>
</div>
}

View file

@ -11,6 +11,7 @@ public partial class NotificationList : IAsyncDisposable
[Inject] private ApiService Api { get; set; } = null!;
private List<NotificationResponse> Notifications { get; set; } = [];
private State _state = State.Loading;
private string? _minId;
private enum State
{
@ -24,12 +25,17 @@ public partial class NotificationList : IAsyncDisposable
try
{
var res = await Api.Notifications.GetNotifications(new PaginationQuery());
Notifications = res;
foreach (var el in res)
if (res.Count > 0)
{
Console.WriteLine(el.Type);
Notifications = res;
_minId = res.Last().Id;
foreach (var el in res)
{
Console.WriteLine(el.Type);
}
}
_state = State.Init;
}
catch (ApiException)
@ -38,6 +44,18 @@ public partial class NotificationList : IAsyncDisposable
}
}
private async Task LoadMore()
{
var pq = new PaginationQuery { MaxId = _minId, Limit = 20 };
var res = await Api.Notifications.GetNotifications(pq);
if (res.Count > 0)
{
Notifications.AddRange(res);
_minId = res.Last().Id;
StateHasChanged();
}
}
protected override async Task OnInitializedAsync()
{
StreamingService.Notification += OnNotification;

View file

@ -3,4 +3,5 @@
align-items: center;
flex-direction: column;
width: 100%;
overflow-x: scroll;;
}

View file

@ -1,5 +1,6 @@
@using Iceshrimp.Frontend.Components
<div class="widget-panel">
Widget Panel goes here.
<NotificationList />
</div>
@code {

View file

@ -1,7 +1,9 @@
.widget-panel{
display: flex;
max-width: 20rem;
min-width: 20rem;
max-width: 23rem;
min-width: 23rem;
position: sticky;
top: 0;
max-height: 100vh;
padding-left: 1rem;
}

View file

@ -0,0 +1,6 @@
@page "/notifications"
@using Iceshrimp.Frontend.Components
<NotificationList />
@code {
}