decord/source/modules/integration_settings/native/IntegrationsSettingsWebhooksOverview.tsx
2026-08-12 06:57:52 +00:00

393 lines
14 KiB
TypeScript

// Module ID: 15988
// Function ID: 15989
// Name: WebhookItem
// Dependencies: [5, 19, 1391, 1980, 1910, 3989, 1922, 15989, 676, 21, 4344, 712, 1499, 1435, 5413, 1297, 1236, 11, 4189, 589, 15990, 8011, 15991, 4072, 1993, 4340, 15993, 5806, 8008, 4752, 5753, 2]
// Exports: default
// Module 15988 (WebhookItem)
import getUncachedChannelPermissions from "getUncachedChannelPermissions";
import importAllResult from "initialize";
import ensureGuildLoaded from "ensureGuildLoaded";
import comparator from "comparator";
import closure_8 from "comparator";
import createGuildRecordFromRust from "createGuildRecordFromRust";
import closure_10 from "getUncachedChannelPermissions";
import mergeGuildAvatar from "mergeGuildAvatar";
import handleWebhookCreateUpdate from "handleWebhookCreateUpdate";
import ME from "ME";
import jsxProd from "RowButtonWrapper";
import createCacheKey from "createCacheKey";
let closure_14;
let closure_15;
let closure_16;
let closure_17;
let closure_18;
let closure_19;
let closure_20;
let closure_6;
let error;
let map1;
const require = arg1;
function WebhookItem(avatar) {
let user;
let webhookId;
avatar = avatar.avatar;
const channel = avatar.channel;
const guildId = avatar.guildId;
const name = avatar.name;
const token = avatar.token;
({ user, webhookId } = avatar);
const webhookType = avatar.webhookType;
let navigation;
let obj = avatar(guildId[12]);
navigation = obj.useNavigation();
const items = [webhookId, webhookType, avatar, channel, guildId, name, token, navigation];
const items1 = [webhookId, avatar];
const callback = token.useCallback(() => {
navigation.push(outer1_14.EDIT_WEBHOOK, { webhookId, webhookType, avatar, name, channel, guildId, token });
}, items);
const memo = token.useMemo(() => {
let obj = avatar(guildId[13]);
obj = { id: webhookId, avatar, discriminator: outer1_15 };
return obj.makeSource(avatar(guildId[13]).getUserAvatarURL(obj));
}, items1);
obj = { icon: null, arrow: true, label: null, subLabel: null, onPress: null };
obj[0] = callback(avatar(guildId[15]).Avatar, { source: memo });
obj[2] = name;
if (null != user) {
const intl2 = tmp(tmp2[16]).intl;
obj = { timestamp: null, user: null };
obj[0] = channel(tmp2[17]).extractTimestamp(webhookId);
const obj6 = channel(tmp2[17]);
obj[1] = channel(tmp2[18]).getUserTag(user);
let formatToPlainStringResult = intl2.formatToPlainString(tmp(tmp2[16]).t["7EcUbr"], obj);
const obj7 = channel(tmp2[18]);
} else {
const intl = tmp(tmp2[16]).intl;
const obj1 = { timestamp: null };
obj1[0] = channel(tmp2[17]).extractTimestamp(webhookId);
formatToPlainStringResult = intl.formatToPlainString(tmp(tmp2[16]).t["7mv59O"], obj1);
const obj4 = channel(tmp2[17]);
}
obj[3] = formatToPlainStringResult;
obj[4] = callback;
return callback(avatar(guildId[14]).TableRow, obj);
}
function ConnectedWebhookItem(arg0) {
let importDefault;
let require;
({ channelId: require, user: importDefault } = arg0);
const merged = Object.assign(arg0, Object.create(null));
let obj = require(589) /* initialize */;
const items = [mergeGuildAvatar];
const stateFromStores = obj.useStateFromStores(items, () => {
let id;
if (id != null) {
id = id.id;
}
return outer1_11.getUser(id);
});
const items1 = [ensureGuildLoaded];
obj = {};
const stateFromStores1 = require(589) /* initialize */.useStateFromStores(items1, () => outer1_5.getChannel(closure_0));
const merged1 = Object.assign(merged);
obj.user = stateFromStores;
obj.channel = stateFromStores1;
return callback(WebhookItem, obj);
}
function CreateWebhookButton(guild) {
guild = guild.guild;
let channel = guild.channel;
let navigation;
let stateFromStores;
let obj = guild(navigation[12]);
navigation = obj.useNavigation();
let items = [closure_8, closure_10];
stateFromStores = guild(navigation[19]).useStateFromStores(items, () => {
if (null != channel) {
return channel;
} else {
const channels = outer1_8.getChannels(guild.id);
const items = [];
HermesBuiltin.arraySpread(channels[outer1_7], HermesBuiltin.arraySpread(channels[outer1_6], 0));
const found = items.find((channel) => closure_10.can(constants.MANAGE_WEBHOOKS, channel.channel));
channel = undefined;
if (found != null) {
channel = found.channel;
}
return channel;
}
});
const items1 = [stateFromStores, guild.id, navigation];
const callback = importAllResult.useCallback(stateFromStores(function*() {
if (c4 === 2) {
c4 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c4 = 2;
if (0 === id) {
if (arg0 === 1) {
c4 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
let arr = tmp5;
let closure_1 = tmp2;
let user;
if (null != id) {
let obj1 = outer1_1(outer1_2[20]);
id = 1;
c4 = 1;
obj1 = { value: null, done: false };
obj1[0] = obj1.create(outer1_0.id, id.id);
return obj1;
} else {
c4 = 3;
}
}
} else if (arg0 === 1) {
c4 = 3;
throw arg1;
} else if (arg0 !== 2) {
user = arg1;
if (null != user) {
const obj2 = { webhookId: null, webhookType: null, avatar: null, name: null, channel: null, guildId: null, token: null };
obj2[0] = user.id;
obj2[1] = user.type;
const avatar = user.avatar;
user = avatar;
if (avatar == null) {
user = undefined;
}
obj2[2] = user;
obj2[3] = user.name;
obj2[4] = id;
obj2[5] = user.id;
obj2[6] = user.token;
arr = arr.push(outer1_14.EDIT_WEBHOOK, obj2);
}
}
c4 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} catch (tmp18) {
c4 = tmp;
throw tmp18;
}
}
}), items1);
obj = { icon: null, label: null, disabled: null, onPress: null };
obj = { IconComponent: null };
obj[0] = guild(navigation[22]).WebhookPlusIcon;
obj[0] = callback(guild(navigation[21]).RowButton.Icon, obj);
const intl = guild(navigation[16]).intl;
obj[1] = intl.string(guild(navigation[16]).t["nrO/HH"]);
obj[2] = null == stateFromStores;
obj[3] = callback;
return callback(guild(navigation[21]).RowButton, obj);
}
let c4 = importAllResult;
({ GUILD_SELECTABLE_CHANNELS_KEY: closure_6, GUILD_VOCAL_CHANNELS_KEY: error } = comparator);
({ HelpdeskArticles: map1, ChannelSettingsSections: closure_14, NON_USER_BOT_DISCRIMINATOR: closure_15, Permissions: closure_16, WebhookTypes: closure_17 } = ME);
({ jsx: closure_18, Fragment: closure_19, jsxs: closure_20 } = jsxProd);
createCacheKey = { form: null, content: null, hint: null };
createCacheKey = { backgroundColor: require("Themes").colors.BACKGROUND_BASE_LOWER };
createCacheKey[0] = createCacheKey;
createCacheKey[1] = { paddingTop: require("Themes").space.PX_16, paddingHorizontal: require("Themes").modules.mobile.TABLE_ROW_PADDING };
let obj1 = { paddingTop: require("Themes").space.PX_16, paddingHorizontal: require("Themes").modules.mobile.TABLE_ROW_PADDING };
createCacheKey[2] = { paddingHorizontal: require("Themes").space.PX_16, marginBottom: require("Themes").space.PX_16 };
createCacheKey = createCacheKey.createLegacyClassComponentStyles(createCacheKey);
const PureComponent = importAllResult.PureComponent;
class WebhooksOverview extends PureComponent {
}
const prototype = WebhooksOverview.prototype;
prototype["getHelpText"] = function getHelpText() {
if (this.props.webhookType === constants2.CHANNEL_FOLLOWER) {
const intl2 = require(1236) /* getSystemLocale */.intl;
let obj = { helpdeskArticle: null };
obj[0] = importDefault(1993).getArticleURL(constants.CHANNEL_FOLLOWING);
let formatResult = intl2.format(require(1236) /* getSystemLocale */.t["5u+aV1"], obj);
const obj4 = importDefault(1993);
} else {
const intl = require(1236) /* getSystemLocale */.intl;
obj = { articleURL: null };
obj[0] = importDefault(1993).getArticleURL(constants.WEBHOOKS_INTRODUCTION);
formatResult = intl.format(require(1236) /* getSystemLocale */.t["3hX7G+"], obj);
const obj2 = importDefault(1993);
}
return formatResult;
};
prototype["renderWebhooks"] = function renderWebhooks() {
let webhookType;
let webhooks;
const self = this;
({ webhooks, webhookType } = this.props);
let found = webhooks;
if (null != webhookType) {
found = webhooks.filter((type) => type.type === webhookType);
}
let dkHRkE = dependencyMap;
const helpText = self.getHelpText();
const items = [callback(webhookType(4340).Text, { variant: "text-sm/medium", color: "text-muted", children: helpText }), , ];
let tmp4Result = webhookType === constants2.INCOMING;
if (tmp4Result) {
let obj = { guild: null, channel: null };
obj[0] = self.props.guild;
obj[1] = self.props.channel;
tmp4Result = tmp4(CreateWebhookButton, obj);
}
items[1] = tmp4Result;
if (0 === found.length) {
obj = { Illustration: null, title: null };
obj[0] = tmp5(15993).WebhookEmpty;
if (webhookType === constants2.CHANNEL_FOLLOWER) {
const intl2 = tmp5(1236).intl;
dkHRkE = tmp5(1236).t.dkHRkE;
let stringResult = intl2.string(dkHRkE);
} else {
const intl = tmp5(1236).intl;
stringResult = intl.string(tmp5(1236).t["4JAVI+"]);
}
obj[1] = stringResult;
tmp4Result = tmp4(tmp5(1297).EmptyState, obj);
} else {
obj = { hasIcons: true, children: null };
obj[1] = found.map((type) => {
let avatar;
let channel_id;
let guild_id;
let id;
let name;
let token;
let user;
({ id, avatar } = type);
const obj = { webhookId: id, webhookType: type.type, avatar: null, name: null, user: null, channelId: null, token: null, guildId: null };
({ name, user, token, guild_id, channel_id } = type);
obj[2] = avatar;
obj[3] = name;
obj[4] = user;
obj[5] = channel_id;
obj[6] = token;
obj[7] = guild_id;
return closure_18(closure_23, obj, id);
});
const obj1 = { children: null };
items[2] = tmp4(tmp5(5806).TableRowGroup, obj);
obj1[0] = items;
return closure_20(closure_19, obj1);
}
};
prototype["render"] = function render() {
const tmp = createCacheKey(this.context);
let obj = { children: null };
obj = { style: tmp.form, contentContainerStyle: this.props.contentContainerStyle, children: null };
obj = { spacing: null, style: null, children: null };
obj[0] = importDefault(712).space.PX_24;
obj[1] = tmp.content;
obj[2] = this.renderWebhooks();
obj[2] = callback(require(4752) /* Stack */.Stack, obj);
const items = [callback(require(8008) /* Form */.Form, obj), callback(require(5753) /* NavScrim */.NavScrim, {})];
obj[0] = items;
return callback2(closure_19, obj);
};
WebhooksOverview.contextType = require("ManaContext").ThemeContext;
let closure_26 = [];
let obj2 = { paddingHorizontal: require("Themes").space.PX_16, marginBottom: require("Themes").space.PX_16 };
const result = require("ensureGuildLoaded").fileFinishedImporting("modules/integration_settings/native/IntegrationsSettingsWebhooksOverview.tsx");
export default function ConnectedWebhooksOverview(channelId) {
let contentContainerStyle;
let webhookType;
channelId = channelId.channelId;
const guildId = channelId.guildId;
let stateFromStores;
let id;
let id1;
({ contentContainerStyle, webhookType } = channelId);
let obj = channelId(stateFromStores[19]);
const items = [ensureGuildLoaded];
stateFromStores = obj.useStateFromStores(items, () => outer1_5.getChannel(channelId));
const items1 = [createGuildRecordFromRust];
const stateFromStores1 = channelId(stateFromStores[19]).useStateFromStores(items1, () => {
let guild_id;
if (stateFromStores != null) {
guild_id = stateFromStores.guild_id;
}
if (guild_id == null) {
guild_id = guildId;
}
return outer1_9.getGuild(guild_id);
});
id = undefined;
if (stateFromStores1 != null) {
id = stateFromStores1.id;
}
if (id == null) {
id = guildId;
}
id1 = undefined;
if (stateFromStores != null) {
id1 = stateFromStores.id;
}
if (id1 == null) {
id1 = channelId;
}
let obj2 = channelId(stateFromStores[19]);
const tmp = channelId;
const tmp2 = stateFromStores;
const items2 = [handleWebhookCreateUpdate];
const items3 = [id, id1];
const stateFromStoresArray = channelId(stateFromStores[19]).useStateFromStoresArray(items2, () => {
if (null != id) {
if (null != id1) {
let webhooksForChannel = outer1_12.getWebhooksForChannel(tmp, tmp2);
}
return webhooksForChannel;
}
if (null != id) {
webhooksForChannel = outer1_12.getWebhooksForGuild(tmp);
} else {
webhooksForChannel = outer1_26;
}
});
const effect = id1.useEffect(() => {
if (null != id) {
if (null != id1) {
const forChannel = guildId(stateFromStores[20]).fetchForChannel(tmp, tmp2);
const obj2 = guildId(stateFromStores[20]);
}
}
if (null != id) {
const forGuild = guildId(stateFromStores[20]).fetchForGuild(tmp);
const obj = guildId(stateFromStores[20]);
}
}, items3);
let tmp9 = null;
if (null != stateFromStores1) {
obj = { guild: null, channel: null, webhooks: null, contentContainerStyle: null, webhookType: null };
obj[0] = stateFromStores1;
obj[1] = stateFromStores;
obj[2] = stateFromStoresArray;
obj[3] = contentContainerStyle;
obj[4] = webhookType;
tmp9 = callback(WebhooksOverview, obj);
}
return tmp9;
};