decord/source/modules/app_dms/useAppDMChatInputState.tsx

151 lines
4.3 KiB
TypeScript
Raw Normal View History

// Module ID: 13392
// Function ID: 13393
// Name: useAppDMChatInputState
// Dependencies: [19, 9419, 4864, 7723, 1918, 1371, 1074, 1894, 504, 8304, 573, 7271, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
// Module 13392 (useAppDMChatInputState)
import DispatcherDefault from "Dispatcher" /* 573 */;
import maybeFetchUserProfileDefault from "maybeFetchUserProfile" /* 8304 */;
import noop from "module_19" /* 19 */;
import ApplicationStore from "ApplicationStore" /* 4864 */;
import UserProfileStore from "UserProfileStore" /* 7723 */;
import ApplicationRecord from "ApplicationRecord" /* 1918 */;
import UserStore from "UserStore" /* 1371 */;
2026-07-23 10:11:24 +00:00
const require = fn;
const useQueryState = fn(9419).useQueryState;
const EMPTY_STRING_SNOWFLAKE_ID = fn(1074).EMPTY_STRING_SNOWFLAKE_ID;
let items = [fn(1894).ApplicationCommandType.PRIMARY_ENTRY_POINT, fn(1894).ApplicationCommandType.CHAT, fn(1894).ApplicationCommandType.MESSAGE, fn(1894).ApplicationCommandType.USER];
const size = fn(2);
const result = size.fileFinishedImporting("modules/app_dms/useAppDMChatInputState.tsx");
2026-07-20 16:05:17 +00:00
export default function useAppDMChatInputState(context) {
2026-07-29 08:29:29 +00:00
let stateFromStores;
2026-07-23 10:11:24 +00:00
let application;
const channel = context.context.channel;
2026-08-24 06:08:38 +00:00
items = [channel];
const memo = application.useMemo(() => {
2026-07-20 16:05:17 +00:00
if (null != channel) {
2026-07-29 08:29:29 +00:00
if (true === obj.isDM()) {
const user = UserStore.getUser(obj.getRecipientId());
2026-07-29 08:29:29 +00:00
let tmp3 = null;
2026-07-20 16:05:17 +00:00
if (undefined !== user) {
2026-07-29 08:29:29 +00:00
tmp3 = null;
2026-07-20 16:05:17 +00:00
if (true === user.bot) {
2026-07-29 08:29:29 +00:00
tmp3 = user;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
return tmp3;
2026-07-20 16:05:17 +00:00
}
}
return null;
}, items);
const items1 = [ApplicationStore];
stateFromStores = channel(stateFromStores[8]).useStateFromStores(items1, () => {
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (memo != null) {
2026-07-20 16:05:17 +00:00
id = memo.id;
}
return ApplicationStore.getAppIdForBotUserId(id);
2026-07-20 16:05:17 +00:00
});
let obj2 = channel(stateFromStores[8]);
const items2 = [UserProfileStore];
2026-07-29 08:29:29 +00:00
const stateFromStores1 = channel(stateFromStores[8]).useStateFromStores(items2, () => {
let tmp2;
2026-07-20 16:05:17 +00:00
if (null !== memo) {
let id;
2026-07-29 08:29:29 +00:00
if (tmp != null) {
id = tmp.id;
2026-07-20 16:05:17 +00:00
}
const userProfile = UserProfileStore.getUserProfile(id);
2026-08-24 06:08:38 +00:00
application = undefined;
2026-07-29 08:29:29 +00:00
if (userProfile != null) {
2026-07-20 16:05:17 +00:00
application = userProfile.application;
}
2026-07-29 08:29:29 +00:00
tmp2 = application;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp2;
2026-07-20 16:05:17 +00:00
});
2026-07-29 08:29:29 +00:00
if (stateFromStores == null) {
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (stateFromStores1 != null) {
2026-07-20 16:05:17 +00:00
id = stateFromStores1.id;
}
2026-07-29 08:29:29 +00:00
stateFromStores = id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const items3 = [memo, stateFromStores];
const effect = obj.useEffect(() => {
if (null == stateFromStores) {
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (memo != null) {
2026-07-20 16:05:17 +00:00
id = memo.id;
}
2026-07-29 08:29:29 +00:00
if (id == null) {
id = EMPTY_STRING_SNOWFLAKE_ID;
2026-07-20 16:05:17 +00:00
}
maybeFetchUserProfileDefault(id, undefined, { withMutualGuilds: true });
2026-07-20 16:05:17 +00:00
}
}, items3);
let id1;
2026-07-29 08:29:29 +00:00
if (memo != null) {
2026-07-20 16:05:17 +00:00
id1 = memo.id;
}
const items4 = [id1];
2026-07-29 08:29:29 +00:00
const effect1 = obj.useEffect(() => {
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (memo != null) {
id = tmp.id;
2026-07-20 16:05:17 +00:00
}
if (null != id) {
const obj2 = { type: "APP_DM_OPEN", botUserId: tmp.id };
DispatcherDefault.dispatch(obj2);
2026-07-20 16:05:17 +00:00
}
}, items4);
const obj5 = { applicationId: stateFromStores, allowFetch: null, allowApplicationState: true };
2026-07-20 16:05:17 +00:00
let id2;
2026-07-29 08:29:29 +00:00
if (memo != null) {
2026-07-20 16:05:17 +00:00
id2 = memo.id;
}
obj5.allowFetch = null != id2;
const descriptors = useQueryState({ channel, type: "channel" }, { commandTypes: items }, obj5).descriptors;
2026-07-20 16:05:17 +00:00
const found = descriptors.find((application) => {
application = application.application;
let id;
2026-07-29 08:29:29 +00:00
if (application != null) {
2026-07-20 16:05:17 +00:00
id = application.id;
}
2026-07-29 08:29:29 +00:00
return id === stateFromStores;
2026-07-20 16:05:17 +00:00
});
2026-07-23 10:11:24 +00:00
application = undefined;
2026-07-29 08:29:29 +00:00
if (found != null) {
2026-07-20 16:05:17 +00:00
application = found.application;
}
const items5 = [application];
2026-07-29 08:29:29 +00:00
let memo1 = obj.useMemo(() => {
2026-07-20 16:05:17 +00:00
let fromServer;
if (null != application) {
fromServer = ApplicationRecord.createFromServer(tmp);
2026-07-20 16:05:17 +00:00
}
return fromServer;
}, items5);
2026-07-29 08:29:29 +00:00
const obj3 = channel(stateFromStores[8]);
const obj4 = { commandTypes: items };
2026-07-20 16:05:17 +00:00
if (null == memo1) {
2026-07-29 08:29:29 +00:00
const tmp15 = stateFromStores;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (memo1 == null) {
memo1 = tmp2Result.useGetOrFetchApplication(tmp15);
2026-07-20 16:05:17 +00:00
}
const obj6 = { application: memo1, isAppDM: null };
2026-07-29 08:29:29 +00:00
let flag;
if (memo != null) {
flag = memo.bot;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flag == null) {
flag = false;
2026-07-20 16:05:17 +00:00
}
obj6.isAppDM = flag;
return obj6;
2026-07-20 16:05:17 +00:00
};