decord/beta/source/modules/messages/useOnMessageSend.tsx

53 lines
1.8 KiB
TypeScript
Raw Normal View History

// Module ID: 16581
// Function ID: 16582
// Name: useOnMessageSend
// Dependencies: [19, 1074, 573, 2]
// Exports: default
// Module 16581 (useOnMessageSend)
import DispatcherDefault from "Dispatcher" /* 573 */;
2026-10-01 14:13:23 +00:00
import Constants from "Constants" /* 1074 */;
import react from "react" /* 19 */;
import size from "module_2" /* 2 */;
2026-10-01 14:13:23 +00:00
const MessageStates = Constants.MessageStates;
const result = size.fileFinishedImporting("modules/messages/useOnMessageSend.tsx");
export default function useOnMessageSend(arg0) {
2026-10-01 14:13:23 +00:00
let closure_0 = arg0;
const tmp = arg1;
let closure_1 = tmp;
const items = [arg0, tmp];
const effect = react.useEffect(() => {
function handleMessage(channelId) {
2026-10-01 14:13:23 +00:00
const tmp2 = undefined !== handleMessageCreate && channelId.channelId !== tmp;
if (!tmp2) {
handleMessage();
}
}
function handleMessageCreate(optimistic) {
2026-10-01 14:13:23 +00:00
optimistic = optimistic.optimistic || optimistic.message.state === constants.SENDING;
if (optimistic) {
2026-10-01 14:13:23 +00:00
const tmp3 = undefined !== handleMessageCreate && optimistic.channelId !== tmp2;
if (!tmp3) {
handleMessage();
}
}
}
2026-10-01 14:13:23 +00:00
let obj = closure_0(closure_1[2]);
const subscription = obj.subscribe("MESSAGE_CREATE", handleMessageCreate);
let obj2 = closure_0(closure_1[2]);
const subscription1 = obj2.subscribe("UPLOAD_START", handleMessage);
let obj3 = closure_0(closure_1[2]);
const subscription2 = obj3.subscribe("CALL_CREATE", handleMessage);
return () => {
2026-10-01 14:13:23 +00:00
const obj = DispatcherDefault;
obj.unsubscribe("MESSAGE_CREATE", handleMessageCreate);
const obj2 = DispatcherDefault;
obj2.unsubscribe("UPLOAD_START", handleMessage);
const obj3 = DispatcherDefault;
obj3.unsubscribe("CALL_CREATE", handleMessage);
};
}, items);
};