decord/beta/source/modules/replies/canReplyToMessage.tsx

130 lines
4.2 KiB
TypeScript
Raw Normal View History

// Module ID: 7418
// Function ID: 7419
// Name: canReplyToMessage
// Dependencies: [32, 4469, 1372, 1074, 1085, 1090, 6687, 7419, 504, 2]
// Exports: canReplyToMessage, useCanReplyToMessage
// Module 7418 (canReplyToMessage)
2026-10-01 14:13:23 +00:00
import Constants2 from "Constants" /* 1085 */;
import MessageTypes from "MessageTypes" /* 1090 */;
import ThreadHooks from "ThreadHooks" /* 6687 */;
import useUserCommunicationDisabled from "useUserCommunicationDisabled" /* 7419 */;
2026-10-01 14:13:23 +00:00
import _slicedToArray from "_slicedToArray" /* 32 */;
import PermissionStore from "PermissionStore" /* 4469 */;
import UserStore from "UserStore" /* 1372 */;
2026-10-01 14:13:23 +00:00
import Constants from "Constants" /* 1074 */;
import size from "module_2" /* 2 */;
const require = globalThis.__r;
2026-10-01 14:13:23 +00:00
let _require, dependencyMap;
2026-10-01 14:13:23 +00:00
let hasOwnProperty;
let metroRequire;
({ MessageFlags: hasOwnProperty, MessageStates: metroRequire } = Constants);
2026-10-01 14:13:23 +00:00
const Permissions = Constants2.Permissions;
const result = size.fileFinishedImporting("modules/replies/canReplyToMessage.tsx");
export const useCanReplyToMessage = function useCanReplyToMessage(channel, message) {
_require = channel;
dependencyMap = message;
let tmp = _require;
2026-10-01 14:13:23 +00:00
const obj = require("ThreadHooks");
const canUnarchiveThread = obj.useCanUnarchiveThread(channel);
const tmp4 = require("useUserCommunicationDisabled");
let guildId;
2026-10-01 14:13:23 +00:00
const useCurrentUserCommunicationDisabled = tmp4.useCurrentUserCommunicationDisabled;
if (channel != null) {
guildId = channel.getGuildId();
}
const items = [PermissionStore];
2026-10-01 14:13:23 +00:00
const tmp6 = _slicedToArray(useCurrentUserCommunicationDisabled(guildId), 2)[1];
const tmpResult = tmp(504);
let stateFromStores = tmpResult.useStateFromStores(items, () => {
let tmp = null != channel && null != message;
if (tmp) {
2026-10-01 14:13:23 +00:00
let hasItem;
const tmp3 = message;
if (channel.isPrivate()) {
hasItem = !obj.isSystemDM();
} else {
hasItem = obj2.can(Permissions.SEND_MESSAGES, obj) && obj2.can(Permissions.READ_MESSAGE_HISTORY, obj);
}
if (hasItem) {
const REPLYABLE = MessageTypes.MessageTypesSets.REPLYABLE;
hasItem = REPLYABLE.has(tmp3.type);
}
tmp = hasItem;
}
return tmp;
});
2026-10-01 14:13:23 +00:00
let tmp8 = null != channel && null != message;
if (tmp8) {
const state = message.state;
const SENT = constants2.SENT;
const hasFlagResult = message.hasFlag(constants.EPHEMERAL);
const isArchivedThreadResult = channel.isArchivedThread();
2026-10-01 14:13:23 +00:00
let tmp13 = !isArchivedThreadResult;
if (isArchivedThreadResult) {
2026-10-01 14:13:23 +00:00
tmp13 = canUnarchiveThread;
}
if (stateFromStores) {
2026-10-01 14:13:23 +00:00
stateFromStores = state === SENT;
}
if (stateFromStores) {
stateFromStores = !hasFlagResult;
}
if (stateFromStores) {
2026-10-01 14:13:23 +00:00
stateFromStores = !tmp6;
}
if (stateFromStores) {
2026-10-01 14:13:23 +00:00
stateFromStores = tmp13;
}
2026-10-01 14:13:23 +00:00
tmp8 = stateFromStores;
}
2026-10-01 14:13:23 +00:00
return tmp8;
};
export const canReplyToMessage = function canReplyToMessage(isPrivate, type) {
2026-10-01 14:13:23 +00:00
let hasItem;
const obj = ThreadHooks;
const canUnarchiveThreadResult = obj.canUnarchiveThread(isPrivate);
if (isPrivate.isPrivate()) {
2026-10-01 14:13:23 +00:00
hasItem = !isPrivate.isSystemDM();
} else {
hasItem = obj2.can(Permissions.SEND_MESSAGES, isPrivate) && obj2.can(Permissions.READ_MESSAGE_HISTORY, isPrivate);
}
if (hasItem) {
const REPLYABLE = tmp(1090).MessageTypesSets.REPLYABLE;
hasItem = REPLYABLE.has(type.type);
}
const currentUser = UserStore.getCurrentUser();
let id;
2026-10-01 14:13:23 +00:00
const userCommunicationDisabled = useUserCommunicationDisabled.userCommunicationDisabled;
useUserCommunicationDisabled;
if (currentUser != null) {
id = currentUser.id;
}
const guildId = isPrivate.getGuildId();
2026-10-01 14:13:23 +00:00
const state = type.state;
const SENT = metroRequire.SENT;
const tmp10 = _slicedToArray(userCommunicationDisabled(id, guildId), 2)[1];
const hasFlagResult = type.hasFlag(hasOwnProperty.EPHEMERAL);
const isArchivedThreadResult = isPrivate.isArchivedThread();
2026-10-01 14:13:23 +00:00
let tmp13 = !isArchivedThreadResult;
if (isArchivedThreadResult) {
2026-10-01 14:13:23 +00:00
tmp13 = canUnarchiveThreadResult;
}
if (hasItem) {
2026-10-01 14:13:23 +00:00
hasItem = state === SENT;
}
if (hasItem) {
hasItem = !hasFlagResult;
}
if (hasItem) {
2026-10-01 14:13:23 +00:00
hasItem = !tmp10;
}
if (hasItem) {
2026-10-01 14:13:23 +00:00
hasItem = tmp13;
}
return hasItem;
};