work around load() bug
This commit is contained in:
parent
ef31b0c375
commit
bb1138579d
3 changed files with 87 additions and 7 deletions
|
|
@ -9,6 +9,7 @@ const Utils = require('../utils')
|
|||
const Wall = require('./wall')
|
||||
const Feed = require('./feed')
|
||||
const User = require('./user')
|
||||
const { size } = require('lodash')
|
||||
|
||||
/**
|
||||
* @param {string} pub
|
||||
|
|
@ -51,7 +52,18 @@ exports.userToIncomingID = async pub => {
|
|||
const getMyUser = async () => {
|
||||
const oldProfile = await Utils.tryAndWait(
|
||||
(_, user) => new Promise(res => user.get(Key.PROFILE).load(res)),
|
||||
v => typeof v !== 'object'
|
||||
v => {
|
||||
if (typeof v !== 'object') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (v === null) {
|
||||
return true
|
||||
}
|
||||
|
||||
// load sometimes returns an empty set on the first try
|
||||
return size(v) === 0
|
||||
}
|
||||
)
|
||||
|
||||
const bio = await Utils.tryAndWait(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
* @format
|
||||
*/
|
||||
const Common = require('shock-common')
|
||||
const size = require('lodash/size')
|
||||
|
||||
const Key = require('../key')
|
||||
const Utils = require('../utils')
|
||||
|
|
@ -72,7 +73,18 @@ module.exports.getAnUser = getAnUser
|
|||
const getMyUser = async () => {
|
||||
const oldProfile = await Utils.tryAndWait(
|
||||
(_, user) => new Promise(res => user.get(Key.PROFILE).load(res)),
|
||||
v => typeof v !== 'object'
|
||||
v => {
|
||||
if (typeof v !== 'object') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (v === null) {
|
||||
return true
|
||||
}
|
||||
|
||||
// load sometimes returns an empty set on the first try
|
||||
return size(v) === 0
|
||||
}
|
||||
)
|
||||
|
||||
const bio = await Utils.tryAndWait(
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ const responseTime = require("response-time");
|
|||
const uuid = require("uuid/v4");
|
||||
const Common = require('shock-common')
|
||||
const isARealUsableNumber = require('lodash/isFinite')
|
||||
const size = require('lodash/size')
|
||||
|
||||
const getListPage = require("../utils/paginate");
|
||||
const auth = require("../services/auth/auth");
|
||||
|
|
@ -2249,7 +2250,18 @@ module.exports = async (
|
|||
u.get(GunKey.USER_TO_INCOMING).load(data => {
|
||||
res(data)
|
||||
})
|
||||
}))
|
||||
}), v => {
|
||||
if (typeof v !== 'object') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (v === null) {
|
||||
return true
|
||||
}
|
||||
|
||||
// load sometimes returns an empty set on the first try
|
||||
return size(v) === 0
|
||||
})
|
||||
|
||||
return res.status(200).json({
|
||||
data
|
||||
|
|
@ -2269,7 +2281,18 @@ module.exports = async (
|
|||
u.get(GunKey.RECIPIENT_TO_OUTGOING).load(data => {
|
||||
res(data)
|
||||
})
|
||||
}))
|
||||
}), v => {
|
||||
if (typeof v !== 'object') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (v === null) {
|
||||
return true
|
||||
}
|
||||
|
||||
// load sometimes returns an empty set on the first try
|
||||
return size(v) === 0
|
||||
})
|
||||
|
||||
return res.status(200).json({
|
||||
data
|
||||
|
|
@ -2289,7 +2312,18 @@ module.exports = async (
|
|||
u.get(GunKey.OUTGOINGS).load(data => {
|
||||
res(data)
|
||||
})
|
||||
}))
|
||||
}), v => {
|
||||
if (typeof v !== 'object') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (v === null) {
|
||||
return true
|
||||
}
|
||||
|
||||
// load sometimes returns an empty set on the first try
|
||||
return size(v) === 0
|
||||
})
|
||||
|
||||
return res.status(200).json({
|
||||
data
|
||||
|
|
@ -2328,7 +2362,18 @@ module.exports = async (
|
|||
res(data)
|
||||
})
|
||||
})
|
||||
)
|
||||
, v => {
|
||||
if (typeof v !== 'object') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (v === null) {
|
||||
return true
|
||||
}
|
||||
|
||||
// load sometimes returns an empty set on the first try
|
||||
return size(v) === 0
|
||||
})
|
||||
|
||||
return res.status(200).json({
|
||||
data
|
||||
|
|
@ -2350,7 +2395,18 @@ module.exports = async (
|
|||
res(data)
|
||||
})
|
||||
})
|
||||
)
|
||||
, v => {
|
||||
if (typeof v !== 'object') {
|
||||
return true
|
||||
}
|
||||
|
||||
if (v === null) {
|
||||
return true
|
||||
}
|
||||
|
||||
// load sometimes returns an empty set on the first try
|
||||
return size(v) === 0
|
||||
})
|
||||
|
||||
return res.status(200).json({
|
||||
data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue