feat: pages pagination loading

This commit is contained in:
DIYgod 2022-09-15 23:51:22 +01:00
parent 0a8a2c3248
commit a79b6a7034
No known key found for this signature in database
GPG Key ID: D159328F47A80DCA
2 changed files with 18 additions and 2 deletions

View File

@ -79,6 +79,7 @@ export type Note = UniNote & {
export type Notes = {
total: number
list: Note[]
cursor?: string
}
export type Profile = UniProfile & {

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",