check return type from gun
This commit is contained in:
parent
0be779b73c
commit
d0349669f9
1 changed files with 18 additions and 13 deletions
|
|
@ -1274,19 +1274,24 @@ const createPost = async (tags, title, content) => {
|
||||||
|
|
||||||
let pageIdx = Math.max(0, numOfPages - 1).toString()
|
let pageIdx = Math.max(0, numOfPages - 1).toString()
|
||||||
|
|
||||||
const count =
|
const count = await (async () => {
|
||||||
numOfPages === 0
|
if (numOfPages === 0) {
|
||||||
? 0
|
return 0
|
||||||
: /** @type {number} */ (await Utils.tryAndWait(
|
}
|
||||||
(_, user) =>
|
|
||||||
user
|
const maybeCount = await Utils.tryAndWait(
|
||||||
.get(Key.WALL)
|
(_, user) =>
|
||||||
.get(Key.PAGES)
|
user
|
||||||
.get(pageIdx)
|
.get(Key.WALL)
|
||||||
.get(Key.COUNT)
|
.get(Key.PAGES)
|
||||||
.then(),
|
.get(pageIdx)
|
||||||
v => typeof v !== 'number'
|
.get(Key.COUNT)
|
||||||
))
|
.then(),
|
||||||
|
v => typeof v !== 'number'
|
||||||
|
)
|
||||||
|
|
||||||
|
return typeof maybeCount === 'number' ? maybeCount : 0
|
||||||
|
})()
|
||||||
|
|
||||||
const shouldBeNewPage =
|
const shouldBeNewPage =
|
||||||
count >= Common.Constants.Misc.NUM_OF_POSTS_PER_WALL_PAGE
|
count >= Common.Constants.Misc.NUM_OF_POSTS_PER_WALL_PAGE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue