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>}
|
* @type {Record<string, Common.Schema.Follow>}
|
||||||
*/
|
*/
|
||||||
const raw = await Utils.tryAndWait(
|
const raw = await Utils.tryAndWait(
|
||||||
// @ts-ignore
|
(_, user) =>
|
||||||
(_, user) => new Promise(res => user.get(Key.FOLLOWS).load(res)),
|
new Promise(res =>
|
||||||
|
// @ts-expect-error
|
||||||
|
user.get(Key.FOLLOWS).load(res)
|
||||||
|
),
|
||||||
v => {
|
v => {
|
||||||
if (typeof v !== 'object' || v === null) {
|
if (typeof v !== 'object' || v === null) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// load sometimes returns an empty set on the first try
|
// 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