Fix inbox pagination cursor and sorting

This commit is contained in:
Sebastian Martinez
2025-04-08 17:53:04 +02:00
parent 7f487be94b
commit 74bb631381
7 changed files with 44 additions and 51 deletions
+2 -2
View File
@@ -13,7 +13,7 @@
clearByIds: (rid: string, ids: string[]) => Promise<void>;
clearByRepo: (rid: string) => Promise<void>;
repo: HomeInboxTab;
items: Record<string, NotificationItem[]>;
items: [string, NotificationItem[]][];
more: boolean;
}
@@ -58,7 +58,7 @@
{/if}
<div class="container">
{#each Object.entries(items).sort((a, b) => b[1][0].timestamp - a[1][0].timestamp) as [_, notificationItems]}
{#each items.sort((a, b) => b[1][0].timestamp - a[1][0].timestamp) as [_, notificationItems]}
<NotificationTeaser
{clearByIds}
rid={repo.rid}
+3 -3
View File
@@ -49,7 +49,7 @@ interface LoadedInboxRoute {
string,
{
repo: HomeInboxTab;
items: Record<string, NotificationItem[]>;
items: [string, NotificationItem[]][];
pagination: { cursor: number; more: boolean };
}
>;
@@ -115,7 +115,7 @@ export async function loadRoute(
new SvelteMap();
if (route.activeTab) {
const items = await invoke<
PaginatedQuery<Record<string, NotificationItem[]>>
PaginatedQuery<[string, NotificationItem[]][]>
>("list_notifications", {
params: {
repo: route.activeTab.rid,
@@ -129,7 +129,7 @@ export async function loadRoute(
} else {
for (const [rid, item] of notificationCount) {
const result = await invoke<
PaginatedQuery<Record<string, NotificationItem[]>>
PaginatedQuery<[string, NotificationItem[]][]>
>("list_notifications", {
params: {
repo: rid,
+12 -11
View File
@@ -25,7 +25,7 @@
string,
{
repo: HomeInboxTab;
items: Record<string, NotificationItem[]>;
items: [string, NotificationItem[]][];
pagination: { cursor: number; more: boolean };
}
>;
@@ -95,7 +95,7 @@
async function reload(rids: string[]) {
for (const rid of rids) {
const [n, count] = await Promise.all([
invoke<PaginatedQuery<Record<string, NotificationItem[]>>>(
invoke<PaginatedQuery<[string, NotificationItem[]][]>>(
"list_notifications",
{
params: {
@@ -124,16 +124,17 @@
async function loadMoreContent() {
if (more && activeTab) {
const c = cursor ? cursor : 20;
const p = await invoke<
PaginatedQuery<Record<string, NotificationItem[]>>
>("list_notifications", {
params: {
repo: activeTab.rid,
skip: more ? c + 20 : c,
take: 20,
const c = cursor ? cursor : 0;
const p = await invoke<PaginatedQuery<[string, NotificationItem[]][]>>(
"list_notifications",
{
params: {
repo: activeTab.rid,
skip: more ? c + 20 : c,
take: 20,
},
},
});
);
cursor = p.cursor;
more = p.more;