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