check return type from gun

This commit is contained in:
Daniel Lugo 2020-06-26 13:00:38 -04:00
parent 0be779b73c
commit d0349669f9

View file

@ -1274,10 +1274,12 @@ const createPost = async (tags, title, content) => {
let pageIdx = Math.max(0, numOfPages - 1).toString()
const count =
numOfPages === 0
? 0
: /** @type {number} */ (await Utils.tryAndWait(
const count = await (async () => {
if (numOfPages === 0) {
return 0
}
const maybeCount = await Utils.tryAndWait(
(_, user) =>
user
.get(Key.WALL)
@ -1286,7 +1288,10 @@ const createPost = async (tags, title, content) => {
.get(Key.COUNT)
.then(),
v => typeof v !== 'number'
))
)
return typeof maybeCount === 'number' ? maybeCount : 0
})()
const shouldBeNewPage =
count >= Common.Constants.Misc.NUM_OF_POSTS_PER_WALL_PAGE