fix(ImplicitRelationships): Use new Flux event (#2392)

main
dolfies 7 months ago committed by GitHub
parent d2941281a4
commit 840c775ed8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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",

Loading…
Cancel
Save