ensure follows gets loaded on first try
This commit is contained in:
parent
aa748323e2
commit
c0f36d71dd
1 changed files with 13 additions and 3 deletions
|
|
@ -21,15 +21,25 @@ exports.currentFollows = async () => {
|
|||
* @type {Record<string, Common.Schema.Follow>}
|
||||
*/
|
||||
const raw = await Utils.tryAndWait(
|
||||
// @ts-ignore
|
||||
(_, user) => new Promise(res => user.get(Key.FOLLOWS).load(res)),
|
||||
(_, user) =>
|
||||
new Promise(res =>
|
||||
// @ts-expect-error
|
||||
user.get(Key.FOLLOWS).load(res)
|
||||
),
|
||||
v => {
|
||||
if (typeof v !== 'object' || v === null) {
|
||||
return true
|
||||
}
|
||||
|
||||
// load sometimes returns an empty set on the first try
|
||||
return size(v) === 0
|
||||
if (size(v) === 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
// sometimes it returns empty sub objects
|
||||
return Object.values(v)
|
||||
.filter(Common.Schema.isObj)
|
||||
.some(obj => size(obj) === 0)
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue