diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-05 17:39:21 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-05 17:39:21 +0200 |
commit | d3039b55ffd3aabe2941ed8c9797e6d290bdb3bc (patch) | |
tree | f9a3fff28999ff9563e8c02fcc6f982e848cb116 /gateway | |
parent | :art: improve migration script (diff) | |
download | server-d3039b55ffd3aabe2941ed8c9797e6d290bdb3bc.tar.xz |
:bug: fix lazy request
Diffstat (limited to '')
-rw-r--r-- | gateway/src/opcodes/LazyRequest.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gateway/src/opcodes/LazyRequest.ts b/gateway/src/opcodes/LazyRequest.ts index db00157f..5b6ac444 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/gateway/src/opcodes/LazyRequest.ts @@ -39,7 +39,7 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) { const items = []; for (const role of roles) { - const [role_members, other_members] = members.partition((m) => + const [role_members, other_members] = partition(members, (m: Member) => m.roles.find((r) => r.id === role.id) ); const group = { @@ -80,3 +80,14 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) { }, }); } + +function partition<T>(array: T[], isValid: Function) { + return array.reduce( + ([pass, fail], elem) => { + return isValid(elem) + ? [[...pass, elem], fail] + : [pass, [...fail, elem]]; + }, + [[], []] + ); +} |