[frontend] Add notification panel to appropriate places
This commit is contained in:
parent
da124c5c98
commit
ffe56307f3
6 changed files with 35 additions and 6 deletions
|
@ -9,6 +9,7 @@
|
|||
{
|
||||
<NotificationComponent NotificationResponse="el" @key="el.Id"/>
|
||||
}
|
||||
<ScrollEnd ManualLoad="LoadMore" IntersectionChange="LoadMore"></ScrollEnd>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
|
|
@ -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,11 +25,16 @@ 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -3,4 +3,5 @@
|
|||
align-items: center;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
overflow-x: scroll;;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
@using Iceshrimp.Frontend.Components
|
||||
<div class="widget-panel">
|
||||
Widget Panel goes here.
|
||||
<NotificationList />
|
||||
</div>
|
||||
@code {
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
6
Iceshrimp.Frontend/Pages/NotificationPage.razor
Normal file
6
Iceshrimp.Frontend/Pages/NotificationPage.razor
Normal file
|
@ -0,0 +1,6 @@
|
|||
@page "/notifications"
|
||||
@using Iceshrimp.Frontend.Components
|
||||
<NotificationList />
|
||||
@code {
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue