decord/source/modules/threads/ThreadMembersStore.tsx

298 lines
9.7 KiB
TypeScript
Raw Normal View History

2026-08-06 08:05:19 +00:00
// Module ID: 7150
// Function ID: 7151
2026-07-29 08:29:29 +00:00
// Name: updateFromGuild
// Dependencies: [1376, 1372, 12, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-08-06 08:05:19 +00:00
// Module 7150 (updateFromGuild)
2026-07-29 08:29:29 +00:00
import { ALL_CHANNEL_TYPES } from "createChannelRecord";
import ensureGuildLoaded from "ensureGuildLoaded";
import { Store } from "initialize";
2026-07-20 16:05:17 +00:00
function updateFromGuild(threads) {
threads = threads.threads;
2026-07-29 08:29:29 +00:00
if (threads != null) {
2026-07-20 16:05:17 +00:00
const item = threads.forEach(updateFromThread);
}
}
function updateFromThread(type) {
let memberCount;
if (ALL_CHANNEL_TYPES.has(type.type)) {
2026-07-23 10:11:24 +00:00
if (!(type.id in dependencyMap)) {
2026-07-29 08:29:29 +00:00
const obj = { guildId: null, parentId: null, memberCount: null, memberIdsPreview: null };
({ guild_id: obj[0], parent_id: obj[1], memberCount } = type);
if (memberCount == null) {
memberCount = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[2] = memberCount;
2026-07-20 16:05:17 +00:00
let memberIdsPreview = type.memberIdsPreview;
2026-07-29 08:29:29 +00:00
if (memberIdsPreview == null) {
2026-07-20 16:05:17 +00:00
memberIdsPreview = [];
}
2026-07-29 08:29:29 +00:00
obj[3] = memberIdsPreview;
2026-07-23 10:11:24 +00:00
dependencyMap[type.id] = obj;
const tmp2 = dependencyMap;
2026-07-20 16:05:17 +00:00
}
if (null != type.memberCount) {
tmp5.memberCount = type.memberCount;
}
if (null != type.memberIdsPreview) {
tmp5.memberIdsPreview = type.memberIdsPreview;
}
} else {
return false;
}
}
function handleThreadCreateOrUpdate(channel) {
2026-07-29 08:29:29 +00:00
let memberCount;
channel = channel.channel;
if (ALL_CHANNEL_TYPES.has(channel.type)) {
if (!(channel.id in dependencyMap)) {
const obj = { guildId: null, parentId: null, memberCount: null, memberIdsPreview: null };
({ guild_id: obj[0], parent_id: obj[1], memberCount } = channel);
if (memberCount == null) {
memberCount = 0;
}
obj[2] = memberCount;
let memberIdsPreview = channel.memberIdsPreview;
if (memberIdsPreview == null) {
memberIdsPreview = [];
}
obj[3] = memberIdsPreview;
dependencyMap[channel.id] = obj;
const tmp2 = dependencyMap;
}
if (null != channel.memberCount) {
tmp5.memberCount = channel.memberCount;
}
if (null != channel.memberIdsPreview) {
tmp5.memberIdsPreview = channel.memberIdsPreview;
}
}
return false;
2026-07-20 16:05:17 +00:00
}
function handleLoadArchivedThreadsSuccess(threads) {
threads = threads.threads;
const item = threads.forEach(updateFromServerThread);
}
function handleSearchMessagesSuccess(data) {
data = data.data;
2026-07-23 10:11:24 +00:00
let c0 = false;
let item = data.forEach((arg0) => {
2026-07-20 16:05:17 +00:00
let messages;
let threads;
({ threads, messages } = arg0);
2026-07-23 10:11:24 +00:00
let item = messages.forEach((arr) => {
2026-07-20 16:05:17 +00:00
const item = arr.forEach((thread) => {
2026-07-29 08:29:29 +00:00
let memberCount;
thread = thread.thread;
let flag = false;
if (null != thread) {
flag = false;
if (!(thread.id in outer1_4)) {
const channel = outer1_3.getChannel(thread.id);
flag = false;
if (null != channel) {
flag = true;
if (outer1_2.has(channel.type)) {
if (!(channel.id in outer1_4)) {
const obj = { guildId: null, parentId: null, memberCount: null, memberIdsPreview: null };
({ guild_id: obj[0], parent_id: obj[1], memberCount } = channel);
if (memberCount == null) {
memberCount = 0;
}
obj[2] = memberCount;
let memberIdsPreview = channel.memberIdsPreview;
if (memberIdsPreview == null) {
memberIdsPreview = [];
}
obj[3] = memberIdsPreview;
outer1_4[channel.id] = obj;
const tmp6 = outer1_4;
}
if (null != channel.memberCount) {
tmp8.memberCount = channel.memberCount;
}
flag = true;
if (null != channel.memberIdsPreview) {
tmp8.memberIdsPreview = channel.memberIdsPreview;
flag = true;
}
}
}
}
}
2026-07-20 16:05:17 +00:00
});
});
2026-07-29 08:29:29 +00:00
const item1 = threads.forEach((id) => {
let memberCount;
let flag = false;
if (null != id) {
flag = false;
if (!(id.id in outer1_4)) {
const channel = outer1_3.getChannel(id.id);
flag = false;
if (null != channel) {
flag = true;
if (outer1_2.has(channel.type)) {
if (!(channel.id in outer1_4)) {
const obj = { guildId: null, parentId: null, memberCount: null, memberIdsPreview: null };
({ guild_id: obj[0], parent_id: obj[1], memberCount } = channel);
if (memberCount == null) {
memberCount = 0;
}
obj[2] = memberCount;
let memberIdsPreview = channel.memberIdsPreview;
if (memberIdsPreview == null) {
memberIdsPreview = [];
}
obj[3] = memberIdsPreview;
outer1_4[channel.id] = obj;
const tmp6 = outer1_4;
}
if (null != channel.memberCount) {
tmp8.memberCount = channel.memberCount;
}
flag = true;
if (null != channel.memberIdsPreview) {
tmp8.memberIdsPreview = channel.memberIdsPreview;
flag = true;
}
}
}
}
}
2026-07-20 16:05:17 +00:00
});
});
2026-07-23 10:11:24 +00:00
return c0;
2026-07-20 16:05:17 +00:00
}
function updateFromServerThread(id) {
2026-07-29 08:29:29 +00:00
let memberCount;
2026-07-20 16:05:17 +00:00
if (null != id) {
2026-07-29 08:29:29 +00:00
if (!(id.id in dependencyMap)) {
2026-07-23 10:11:24 +00:00
channel = channel.getChannel(id.id);
2026-07-20 16:05:17 +00:00
if (null != channel) {
2026-07-29 08:29:29 +00:00
if (ALL_CHANNEL_TYPES.has(channel.type)) {
if (!(channel.id in dependencyMap)) {
const obj = { guildId: null, parentId: null, memberCount: null, memberIdsPreview: null };
({ guild_id: obj[0], parent_id: obj[1], memberCount } = channel);
if (memberCount == null) {
memberCount = 0;
}
obj[2] = memberCount;
let memberIdsPreview = channel.memberIdsPreview;
if (memberIdsPreview == null) {
memberIdsPreview = [];
}
obj[3] = memberIdsPreview;
dependencyMap[channel.id] = obj;
const tmp4 = dependencyMap;
}
if (null != channel.memberCount) {
tmp6.memberCount = channel.memberCount;
}
if (null != channel.memberIdsPreview) {
tmp6.memberIdsPreview = channel.memberIdsPreview;
}
}
2026-07-20 16:05:17 +00:00
return true;
}
}
}
return false;
}
2026-07-29 08:29:29 +00:00
let closure_4 = {};
class ThreadMembersStore extends Store {
}
const prototype = ThreadMembersStore.prototype;
prototype["initialize"] = function initialize() {
this.waitFor(ensureGuildLoaded);
};
prototype["getMemberCount"] = function getMemberCount(arg0) {
let memberCount;
if (dependencyMap[arg0] != null) {
memberCount = tmp.memberCount;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (memberCount == null) {
memberCount = null;
}
return memberCount;
};
prototype["getMemberIdsPreview"] = function getMemberIdsPreview(arg0) {
let memberIdsPreview;
if (dependencyMap[arg0] != null) {
memberIdsPreview = tmp.memberIdsPreview;
}
if (memberIdsPreview == null) {
memberIdsPreview = null;
}
return memberIdsPreview;
};
prototype["getInitialOverlayState"] = function getInitialOverlayState() {
return closure_4;
};
ThreadMembersStore.displayName = "ThreadMembersStore";
const threadMembersStore = new ThreadMembersStore(require("dispatcher"), {
2026-07-20 16:05:17 +00:00
CONNECTION_OPEN: function handleConnectionOpen(guilds) {
2026-07-29 08:29:29 +00:00
let closure_4 = {};
2026-07-20 16:05:17 +00:00
guilds = guilds.guilds;
const item = guilds.forEach(updateFromGuild);
},
OVERLAY_INITIALIZE: function handleOverlayInitialize(threadMembers) {
2026-07-23 10:11:24 +00:00
const obj = {};
2026-07-20 16:05:17 +00:00
const merged = Object.assign(threadMembers.threadMembers);
},
GUILD_CREATE: function handleGuildCreate(guild) {
2026-07-29 08:29:29 +00:00
const threads = guild.guild.threads;
if (threads != null) {
const item = threads.forEach(updateFromThread);
}
2026-07-20 16:05:17 +00:00
},
GUILD_DELETE: function handleGuildDelete(guild) {
2026-07-29 08:29:29 +00:00
const id = guild.guild.id;
closure_4 = id(12).omitBy(closure_4, (guildId) => guildId.guildId === id);
2026-07-20 16:05:17 +00:00
},
CHANNEL_DELETE: function handleChannelDelete(channel) {
2026-07-29 08:29:29 +00:00
const id = channel.channel.id;
closure_4 = id(12).omitBy(closure_4, (parentId) => parentId.parentId === id);
2026-07-20 16:05:17 +00:00
},
THREAD_CREATE: handleThreadCreateOrUpdate,
THREAD_UPDATE: handleThreadCreateOrUpdate,
THREAD_LIST_SYNC: function handleThreadListSync(threads) {
threads = threads.threads;
const item = threads.forEach(updateFromThread);
},
THREAD_MEMBERS_UPDATE: function handleThreadMembersUpdate(memberIdsPreview) {
2026-07-23 10:11:24 +00:00
if (null == dependencyMap[memberIdsPreview.id]) {
2026-07-20 16:05:17 +00:00
return false;
} else {
if (null != memberIdsPreview.memberIdsPreview) {
tmp.memberIdsPreview = memberIdsPreview.memberIdsPreview;
}
tmp.memberCount = memberIdsPreview.memberCount;
}
},
SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
MOD_VIEW_SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
LOAD_THREADS_SUCCESS: handleLoadArchivedThreadsSuccess,
LOAD_ARCHIVED_THREADS_SUCCESS: handleLoadArchivedThreadsSuccess,
THREAD_DELETE: function handleThreadDelete(arg0) {
2026-07-23 10:11:24 +00:00
delete tmp2[tmp];
2026-07-20 16:05:17 +00:00
},
2026-07-29 08:29:29 +00:00
LOAD_MESSAGES_SUCCESS: function handleLoadMessagesSuccess(arg0) {
2026-07-20 16:05:17 +00:00
let flag = false;
2026-07-29 08:29:29 +00:00
for (const item10007 of tmp) {
let tmp2 = updateFromServerThread;
let tmp3 = updateFromServerThread(item10007.thread);
if (!tmp3) {
tmp3 = flag;
}
flag = tmp3;
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return flag;
2026-07-20 16:05:17 +00:00
}
});
2026-07-29 08:29:29 +00:00
const result = require("apply").fileFinishedImporting("modules/threads/ThreadMembersStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default threadMembersStore;