no retry if page count is zero
This commit is contained in:
parent
64c16d88e7
commit
54f223ac99
1 changed files with 28 additions and 4 deletions
|
|
@ -44,11 +44,13 @@ const getWallPage = async (page, publicKey) => {
|
|||
)
|
||||
}
|
||||
|
||||
const empty = {
|
||||
count: 0,
|
||||
posts: {}
|
||||
}
|
||||
|
||||
if (totalPages === 0) {
|
||||
return {
|
||||
count: 0,
|
||||
posts: {}
|
||||
}
|
||||
return empty
|
||||
}
|
||||
|
||||
const actualPageIdx = page < 0 ? totalPages + page : page - 1
|
||||
|
|
@ -57,6 +59,28 @@ const getWallPage = async (page, publicKey) => {
|
|||
throw new RangeError(`Requested a page out of bounds`)
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
// @ts-ignore
|
||||
const count = await Utils.tryAndWait(
|
||||
(g, u) => {
|
||||
const user = publicKey ? g.get(`~${publicKey}`) : u
|
||||
|
||||
return user
|
||||
.get(Key.WALL)
|
||||
.get(Key.PAGES)
|
||||
.get(actualPageIdx.toString())
|
||||
.get(Key.COUNT)
|
||||
.then()
|
||||
},
|
||||
v => typeof v !== 'number'
|
||||
)
|
||||
|
||||
if (count === 0) {
|
||||
return empty
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Common.SchemaTypes.WallPage}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue