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() 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( }
const maybeCount = await Utils.tryAndWait(
(_, user) => (_, user) =>
user user
.get(Key.WALL) .get(Key.WALL)
@ -1286,7 +1288,10 @@ const createPost = async (tags, title, content) => {
.get(Key.COUNT) .get(Key.COUNT)
.then(), .then(),
v => typeof v !== 'number' 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