refactor: promise at once
This commit is contained in:
parent
52e9ba73df
commit
17161c9ba2
1 changed files with 13 additions and 9 deletions
|
@ -91,12 +91,20 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (scyllaClient) {
|
if (scyllaClient) {
|
||||||
const channelCache = await ChannelFollowingsCache.init(user.id);
|
const [
|
||||||
const followingChannelIds = await channelCache.getAll();
|
followingChannelIds,
|
||||||
const followingUserIds = await followingsCache.getAll();
|
followingUserIds,
|
||||||
|
mutedUserIds,
|
||||||
|
blockerIds,
|
||||||
|
renoteMutedIds,
|
||||||
|
] = await Promise.all([
|
||||||
|
ChannelFollowingsCache.init(user.id).then((cache) => cache.getAll()),
|
||||||
|
followingsCache.getAll(),
|
||||||
|
UserMutingsCache.init(user.id).then((cache) => cache.getAll()),
|
||||||
|
UserBlockedCache.init(user.id).then((cache) => cache.getAll()),
|
||||||
|
RenoteMutingsCache.init(user.id).then((cache) => cache.getAll()),
|
||||||
|
]);
|
||||||
const validUserIds = [user.id].concat(followingUserIds);
|
const validUserIds = [user.id].concat(followingUserIds);
|
||||||
const userMutingsCache = await UserMutingsCache.init(user.id);
|
|
||||||
const mutedUserIds = await userMutingsCache.getAll();
|
|
||||||
const mutedWords =
|
const mutedWords =
|
||||||
(await userWordMuteCache.fetchMaybe(user.id, () =>
|
(await userWordMuteCache.fetchMaybe(user.id, () =>
|
||||||
UserProfiles.findOne({
|
UserProfiles.findOne({
|
||||||
|
@ -104,10 +112,6 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
where: { userId: user.id },
|
where: { userId: user.id },
|
||||||
}).then((profile) => profile?.mutedWords),
|
}).then((profile) => profile?.mutedWords),
|
||||||
)) ?? [];
|
)) ?? [];
|
||||||
const blockedCache = await UserBlockedCache.init(user.id);
|
|
||||||
const blockerIds = await blockedCache.getAll();
|
|
||||||
const renoteMutingsCache = await RenoteMutingsCache.init(user.id);
|
|
||||||
const renoteMutedIds = await renoteMutingsCache.getAll();
|
|
||||||
const optFilter = (n: ScyllaNote) =>
|
const optFilter = (n: ScyllaNote) =>
|
||||||
!n.renoteId || !!n.text || n.files.length > 0 || n.hasPoll;
|
!n.renoteId || !!n.text || n.files.length > 0 || n.hasPoll;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue