From 840c775ed8b38b80ab12f3b570d0ef40bae2c6ff Mon Sep 17 00:00:00 2001 From: dolfies Date: Sat, 27 Apr 2024 16:29:29 -0400 Subject: [PATCH] fix(ImplicitRelationships): Use new Flux event (#2392) --- src/plugins/implicitRelationships/index.ts | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index 9ae9fb51..be17e0fe 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -151,20 +151,25 @@ export default definePlugin({ // OP 8 Request Guild Members allows 100 user IDs at a time const ignore = new Set(toRequest); const relationships = RelationshipStore.getRelationships(); - const callback = ({ nonce, members }) => { - if (nonce !== sentNonce) return; - members.forEach(member => { - ignore.delete(member.user.id); - }); + const callback = ({ chunks }) => { + for (const chunk of chunks) { + const { nonce, members } = chunk; + if (nonce !== sentNonce) return; + members.forEach(member => { + ignore.delete(member.user.id); + }); - nonFriendAffinities.map(id => UserStore.getUser(id)).filter(user => user && !ignore.has(user.id)).forEach(user => relationships[user.id] = 5); - RelationshipStore.emitChange(); - if (--count === 0) { - FluxDispatcher.unsubscribe("GUILD_MEMBERS_CHUNK", callback); + nonFriendAffinities.map(id => UserStore.getUser(id)).filter(user => user && !ignore.has(user.id)).forEach(user => relationships[user.id] = 5); + RelationshipStore.emitChange(); + if (--count === 0) { + // @ts-ignore + FluxDispatcher.unsubscribe("GUILD_MEMBERS_CHUNK_BATCH", callback); + } } }; - FluxDispatcher.subscribe("GUILD_MEMBERS_CHUNK", callback); + // @ts-ignore + FluxDispatcher.subscribe("GUILD_MEMBERS_CHUNK_BATCH", callback); for (let i = 0; i < toRequest.length; i += 100) { FluxDispatcher.dispatch({ type: "GUILD_MEMBERS_REQUEST",