feat: pages pagination loading

This commit is contained in:
DIYgod
2022-09-15 23:51:22 +01:00
parent 0a8a2c3248
commit a79b6a7034
2 changed files with 18 additions and 2 deletions
+1
View File
@@ -79,6 +79,7 @@ export type Note = UniNote & {
export type Notes = {
total: number
list: Note[]
cursor?: string
}
export type Profile = UniProfile & {
+17 -2
View File
@@ -199,7 +199,7 @@ export async function getPagesBySite(input: {
const visibility = input.visibility || PageVisibilityEnum.All
let pages: Notes = (await unidata.notes.get({
const options = {
source: "Crossbell Note",
identity: input.site,
platform: "Crossbell",
@@ -208,11 +208,26 @@ export async function getPagesBySite(input: {
tags: [...(input.tags || []), input.type],
applications: ["xlog"],
},
})) || {
cursor: "",
}
let pages: Notes = {
total: 0,
list: [],
}
let cursor = ""
do {
options.cursor = cursor
const res = (await unidata.notes.get(options)) || {
total: 0,
list: [],
}
pages.total = res.total
pages.list = pages.list.concat(res.list)
cursor = res.cursor
} while (cursor)
const local = getLocalPages({
site: input.site,
isPost: input.type === "post",