mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Fix inbox pagination cursor and sorting
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user