Files
discord-decomp/modules/messages/setupLoadFromMessageManagerHandlers.tsx
T
2026-11-01 12:12:55 +02:00

75 lines
2.3 KiB
TypeScript

// Metro module 16248 (f16249).
export default function setupLoadFromMessageManagerHandlers(a0, c22920_0, r11 = {}) {
let onBeforeBatch, c22920_2;
onBeforeBatch = void 0;
c22920_2 = void 0;
const handleMessage = function handleMessage({ message }) {
if (message.channel_id != null && c22920_2.has(message.channel_id)) {
if (onBeforeBatch != null) {
onBeforeBatch();
}
if (message.channel_id != null && c22920_2.has(message.channel_id)) {
c22920_0(message);
}
}
};
const handleLoadMessages = function handleLoadMessages({ channelId, messages }) {
c22920_2.add(channelId);
if (onBeforeBatch != null) {
onBeforeBatch();
}
messages.forEach((message) => {
if (message.channel_id != null && c22920_2.has(message.channel_id)) {
c22920_0(message);
}
});
};
const handleSearchMessagesSuccess = function handleSearchMessagesSuccess({ data }) {
if (onBeforeBatch != null) {
onBeforeBatch();
}
data.forEach((a0) => {
a0.messages.forEach((message) => {
message.forEach((item) => c22920_0(item));
});
});
};
onBeforeBatch = r11.onBeforeBatch;
c22920_2 = new Set();
a0.actions = {
...a0.actions,
POST_CONNECTION_OPEN: function POST_CONNECTION_OPEN() {
c22920_2.clear();
},
MESSAGE_CREATE: {
callback: handleMessage,
autoSubscribe: false
},
MESSAGE_UPDATE: handleMessage,
LOAD_MESSAGES_SUCCESS: handleLoadMessages,
LOAD_MESSAGES_AROUND_SUCCESS: handleLoadMessages,
LOAD_RECENT_MENTIONS_SUCCESS: function LOAD_RECENT_MENTIONS_SUCCESS({ messages }) {
if (onBeforeBatch != null) {
onBeforeBatch();
}
messages.forEach((message) => c22920_0(message));
},
LOAD_PINNED_MESSAGES_SUCCESS: function LOAD_PINNED_MESSAGES_SUCCESS({ pins }) {
if (onBeforeBatch != null) {
onBeforeBatch();
}
pins.forEach((pin) => c22920_0(pin.message));
},
SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
MOD_VIEW_SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
CHANNEL_SELECT: {
callback: function callback({ channelId }) {
if (channelId != null) {
c22920_2.add(channelId);
}
},
autoSubscribe: false
}
};
};