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

36 lines
1.2 KiB
TypeScript

// Metro module 15585 (f15586).
import { useEffect } from "react";
import { MessageStates } from "../../Constants";
import Dispatcher from "../../Dispatcher";
export default function useOnMessageSend(a0) {
let c22216_0 = a0;
let r5 = arguments[1];
if (r5 === void 0) {
r5 = void 0;
}
let c22216_1 = r5;
useEffect(() => {
let handleMessageCreate2;
const handleMessage2 = function handleMessage(a0) {
if (!(c22216_1 !== void 0 && a0.channelId !== c22216_1)) {
c22216_0();
}
};
handleMessageCreate2 = function handleMessageCreate(a0) {
if (a0.optimistic || a0.message.state === MessageStates.SENDING) {
if (!(c22216_1 !== void 0 && a0.channelId !== c22216_1)) {
c22216_0();
}
}
};
Dispatcher.subscribe("MESSAGE_CREATE", handleMessageCreate2);
Dispatcher.subscribe("UPLOAD_START", handleMessage2);
Dispatcher.subscribe("CALL_CREATE", handleMessage2);
return () => {
Dispatcher.unsubscribe("MESSAGE_CREATE", handleMessageCreate2);
Dispatcher.unsubscribe("UPLOAD_START", handleMessage2);
Dispatcher.unsubscribe("CALL_CREATE", handleMessage2);
};
}, [a0, r5]);
};