decord/source/components_native/channel_settings/ChannelSettingsPermissionsOverview.tsx

458 lines
18 KiB
TypeScript
Raw Normal View History

// Module ID: 16865
// Function ID: 16866
// Name: ChannelSettingsPermissionsOverview
// Dependencies: [32, 5, 19, 17, 2016, 1957, 2015, 1979, 4222, 1371, 1074, 21, 4574, 576, 4918, 1114, 4727, 4217, 11641, 9772, 8658, 12, 5701, 5619, 15188, 1483, 12783, 10302, 15344, 504, 1894, 10974, 16866, 5595, 7877, 4587, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
// Module 16865 (ChannelSettingsPermissionsOverview)
import _modDef12 from "module_12" /* 12 */;
import nativeDefault from "native" /* 576 */;
import util from "util" /* 1114 */;
import Server from "Server" /* 1894 */;
import PermissionUtilsAll from "PermissionUtils" /* 4217 */;
import ChannelActionCreatorsDefault from "ChannelActionCreators" /* 4587 */;
import DeprecatedLayoutAnimation from "DeprecatedLayoutAnimation" /* 5595 */;
import TableRow from "TableRow" /* 5619 */;
import RoleLabel from "RoleLabel" /* 10302 */;
import DetailedGuildIdentityUserRowDefault from "DetailedGuildIdentityUserRow" /* 10974 */;
import CircleMinusIcon from "CircleMinusIcon" /* 15344 */;
import useGetOrFetchChannelOverwriteUsersDefault from "useGetOrFetchChannelOverwriteUsers" /* 16866 */;
import _slicedToArray from "module_32" /* 32 */;
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
import noop from "module_19" /* 19 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import GuildRoleStore from "GuildRoleStore" /* 2015 */;
import GuildStore from "GuildStore" /* 1979 */;
import RelationshipStore from "RelationshipStore" /* 4222 */;
import UserStore from "UserStore" /* 1371 */;
2026-07-23 10:11:24 +00:00
require = fn;
2026-07-20 16:05:17 +00:00
function ChannelPermissionSyncModule(channel) {
channel = channel.channel;
const category = channel.category;
const items = [channel, category];
const callback = noop.useCallback(() => {
let obj2 = { title: null, body: null, confirmText: null, cancelText: null, onConfirm: null };
const intl = channel(1114).intl;
obj2.title = intl.string(channel(1114).t.YWMtRe);
const intl2 = channel(1114).intl;
let obj3 = { channelName: null, categoryName: null };
let obj = category(4918);
obj3.channelName = channel(4727).computeChannelName(closure_0, UserStore, RelationshipStore, true);
let obj4 = channel(4727);
obj3.categoryName = channel(4727).computeChannelName(category, UserStore, RelationshipStore);
obj2.body = intl2.format(channel(1114).t["iKW+jY"], obj3);
const intl3 = channel(1114).intl;
obj2.confirmText = intl3.string(channel(1114).t.eW8Gy4);
const intl4 = channel(1114).intl;
obj2.cancelText = intl4.string(channel(1114).t.s4uM3b);
closure_0 = asyncGeneratorStep(async (arg0, value) => {
2026-07-29 08:29:29 +00:00
if (c3 === 2) {
c3 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
2026-09-02 09:53:35 +00:00
} else if (tmp4 === 3) {
2026-07-29 08:29:29 +00:00
if (arg0 === 1) {
throw value;
2026-07-29 08:29:29 +00:00
} else if (arg0 === 2) {
const obj2 = { value, done: true };
return obj2;
2026-07-29 08:29:29 +00:00
} else {
2026-09-01 10:26:29 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c3 = 2;
if (0 === c2) {
if (arg0 === 1) {
c3 = 3;
throw value;
2026-07-29 08:29:29 +00:00
} else if (arg0 === 2) {
c3 = 3;
const obj4 = { value, done: true };
return obj4;
2026-07-29 08:29:29 +00:00
} else {
closure_128_0 = undefined;
const guild_id = tmp5.guild_id;
const obj8 = PermissionUtilsAll;
const syncedPermissionOverwrites = obj8.getSyncedPermissionOverwrites(tmp5, tmp2(11641).getAppChannelBotUserId(tmp2));
closure_128_0 = syncedPermissionOverwrites;
const obj9 = tmp2(11641);
2026-07-29 08:29:29 +00:00
c2 = 1;
c3 = 1;
const obj5 = { value: tmp2(9772).checkChattableChannelThresholdMetAfterChannelPermissionDeny(tmp2, syncedPermissionOverwrites[guild_id].deny, syncedPermissionOverwrites[guild_id].allow), done: false };
return obj5;
2026-07-29 08:29:29 +00:00
}
} else if (arg0 === 1) {
c3 = 3;
throw value;
2026-07-29 08:29:29 +00:00
} else if (arg0 === 2) {
c3 = 3;
const obj6 = { value, done: true };
return obj6;
2026-07-29 08:29:29 +00:00
} else {
if (value) {
const obj7 = { permissionOverwrites: null };
const obj = tmp2(8658);
obj7.permissionOverwrites = category(12).values(closure_128_0);
obj.saveChannel(tmp2.id, obj7);
const obj3 = category(12);
2026-07-29 08:29:29 +00:00
}
c3 = 3;
2026-09-01 10:26:29 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
2026-09-02 09:53:35 +00:00
} catch (tmp15) {
2026-07-29 08:29:29 +00:00
c3 = tmp;
2026-09-02 09:53:35 +00:00
throw tmp15;
2026-07-29 08:29:29 +00:00
}
}
});
obj2.onConfirm = function() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = closure_0.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
};
obj.show(obj2);
2026-07-20 16:05:17 +00:00
}, items);
const tmp = closure_18();
const channelName = channel(4727).computeChannelName(category, UserStore, RelationshipStore);
let obj2 = { style: tmp.tableRowGroupContainer, children: null };
let intl = channel(1114).intl;
2026-07-20 16:05:17 +00:00
const formatToPlainString = intl.formatToPlainString;
const t = channel(1114).t;
2026-07-20 16:05:17 +00:00
if (channel.locked) {
let obj3 = { categoryName: channelName };
let formatToPlainStringResult = formatToPlainString(t.ETJqLl, obj3);
2026-07-20 16:05:17 +00:00
} else {
let obj4 = { categoryName: channelName };
formatToPlainStringResult = formatToPlainString(t.OIhm0M, obj4);
2026-07-20 16:05:17 +00:00
}
let obj5 = { title: formatToPlainStringResult, hasIcons: true, children: null };
let obj6 = { icon: closure_16(channel(15188).RefreshIcon, {}), label: null, onPress: null };
let intl2 = tmp3(1114).intl;
obj6.label = intl2.string(channel(1114).t.NVwuHq);
obj6.onPress = callback;
obj5.children = closure_16(channel(5619).TableRow, obj6);
obj2.children = closure_16(channel(5701).TableRowGroup, obj5);
return closure_16(View, obj2);
2026-07-20 16:05:17 +00:00
}
function CategorySync(category) {
category = category.category;
let tmp4 = null;
if (null != category) {
tmp4 = null;
if (!tmp2) {
const obj = { channel: tmp, category, locked: tmp3 };
tmp4 = value2(ChannelPermissionSyncModule, obj);
2026-07-20 16:05:17 +00:00
}
}
return tmp4;
}
function AddPermission(isEditing) {
_require = undefined;
const tmp = closure_18();
_require = require("useNavigation").useNavigation();
2026-07-20 16:05:17 +00:00
if (isEditing.isEditing) {
return null;
} else {
const obj2 = { style: tmp.tableRowGroupContainer, children: null };
const obj3 = { title: null, hasIcons: true, children: null };
const intl = tmp2(1114).intl;
obj3.title = intl.string(tmp2(1114).t.vPHdP5);
const obj4 = { icon: closure_16(tmp2(12783).PlusMediumIcon, {}), label: null, onPress: null };
const intl2 = tmp2(1114).intl;
obj4.label = intl2.string(tmp2(1114).t.fVWxvT);
obj4.onPress = function onPress() {
closure_0.push(constants2.NEW_PERMISSION, { type: constants.ROLE });
2026-07-20 16:05:17 +00:00
};
const items = [closure_16(tmp2(5619).TableRow, obj4), ];
const obj5 = { icon: closure_16(tmp2(12783).PlusMediumIcon, {}), label: null, onPress: null };
const intl3 = tmp2(1114).intl;
obj5.label = intl3.string(tmp2(1114).t.riesLt);
obj5.onPress = function onPress() {
closure_0.push(constants2.NEW_PERMISSION, { type: constants.MEMBER });
2026-07-20 16:05:17 +00:00
};
items[1] = closure_16(tmp2(5619).TableRow, obj5);
obj3.children = items;
obj2.children = closure_17(tmp2(5701).TableRowGroup, obj3);
return closure_16(View, obj2);
2026-07-20 16:05:17 +00:00
}
const obj = require("useNavigation");
2026-07-20 16:05:17 +00:00
}
function RoleRow(onDelete) {
({ role, isEditing, onSelect } = onDelete);
({ name, colorString, colorStrings } = role);
const tmp = isEveryoneRole(role);
const obj = { label: value2(RoleLabel.RoleLabel, { name, color: colorString, colors: colorStrings }), arrow: !isEditing, icon: null, onPress: null };
2026-07-29 08:29:29 +00:00
let tmp2Result = null;
2026-07-20 16:05:17 +00:00
if (isEditing) {
2026-07-29 08:29:29 +00:00
tmp2Result = null;
2026-07-20 16:05:17 +00:00
if (!tmp) {
const obj2 = { color: nativeDefault.colors.ICON_FEEDBACK_CRITICAL, accessibilityLabel: null };
const intl = tmp3(1114).intl;
obj2.accessibilityLabel = intl.string(tmp3(1114).t.N86XcP);
tmp2Result = tmp2(tmp3(15344).CircleMinusIcon, obj2);
2026-07-20 16:05:17 +00:00
}
}
obj.icon = tmp2Result;
2026-07-20 16:05:17 +00:00
onDelete = onSelect;
if (isEditing) {
onDelete = onSelect;
if (!tmp) {
onDelete = onDelete.onDelete;
}
}
obj.onPress = onDelete;
return value2(TableRow.TableRow, obj);
2026-07-20 16:05:17 +00:00
}
function RoleOverwrites(guild) {
guild = guild.guild;
2026-07-23 10:11:24 +00:00
({ isEditing: importDefault, onSelectRow: importAll, onDeleteRow: dependencyMap } = guild);
const tmp = closure_18();
const items = [GuildRoleStore];
const stateFromStores = guild(504).useStateFromStores(items, () => GuildRoleStore.getSortedRoles(guild.id));
const obj2 = {};
2026-07-20 16:05:17 +00:00
const merged = Object.assign(guild.channel.permissionOverwrites);
if (null == obj2[guild.id]) {
obj2[guild.id] = PermissionUtilsAll.makeEveryoneOverwrite(guild.id);
2026-07-20 16:05:17 +00:00
}
const found = stateFromStores.filter((item) => {
2026-07-20 16:05:17 +00:00
let type;
if (obj2[item.id] != null) {
2026-07-20 16:05:17 +00:00
type = tmp.type;
}
return type === Server.PermissionOverwriteType.ROLE;
2026-07-20 16:05:17 +00:00
});
const obj4 = { style: tmp.tableRowGroupContainer, children: null };
const obj5 = { title: null, hasIcons: true, children: null };
const intl = tmp2(1114).intl;
obj5.title = intl.string(guild(1114).t["LPJmL/"]);
obj5.children = found.map((role) => {
const user = role;
return closure_1_16(RoleRow, {
role,
isEditing,
2026-07-20 16:05:17 +00:00
onSelect() {
return importAll(user.id);
2026-07-20 16:05:17 +00:00
},
onDelete() {
return dependencyMap(user.id);
2026-07-20 16:05:17 +00:00
}
}, role.id);
2026-07-20 16:05:17 +00:00
});
obj4.children = closure_16(guild(5701).TableRowGroup, obj5);
return closure_16(View, obj4);
2026-07-20 16:05:17 +00:00
}
function MemberRow(arg0) {
({ isEditing, onSelect } = arg0);
({ guildId, user, onDelete } = arg0);
const obj = { userId: user.id, guildId, onPress: null, arrow: null, leading: null };
2026-07-20 16:05:17 +00:00
if (isEditing) {
onSelect = onDelete;
}
obj.onPress = onSelect;
obj.arrow = !isEditing;
2026-07-29 08:29:29 +00:00
let tmpResult = null;
2026-07-20 16:05:17 +00:00
if (isEditing) {
const obj2 = { color: nativeDefault.colors.ICON_FEEDBACK_CRITICAL, accessibilityLabel: null };
const intl = util.intl;
obj2.accessibilityLabel = intl.string(util.t.N86XcP);
tmpResult = tmp(CircleMinusIcon.CircleMinusIcon, obj2);
2026-07-20 16:05:17 +00:00
}
obj.leading = tmpResult;
return value2(DetailedGuildIdentityUserRowDefault, obj);
2026-07-20 16:05:17 +00:00
}
function MemberOverwrites(channel) {
channel = channel.channel;
2026-07-23 10:11:24 +00:00
const guild_id = channel.guild_id;
({ isEditing: importDefault, onSelectRow: importAll, onDeleteRow: dependencyMap } = channel);
const tmp = closure_18();
2026-09-02 09:53:35 +00:00
const tmp3 = useGetOrFetchChannelOverwriteUsersDefault(guild_id, channel.permissionOverwrites);
const obj = _modDef12(useGetOrFetchChannelOverwriteUsersDefault(guild_id, channel.permissionOverwrites));
const valueResult = _modDef12(useGetOrFetchChannelOverwriteUsersDefault(guild_id, channel.permissionOverwrites)).sortBy((username) => username.username.toLowerCase()).value();
2026-07-29 08:29:29 +00:00
let tmp4 = null;
2026-07-20 16:05:17 +00:00
if (valueResult.length > 0) {
const obj2 = { style: tmp.tableRowGroupContainer, children: null };
const obj3 = { title: null, hasIcons: true, children: null };
const intl = guild_id(1114).intl;
obj3.title = intl.string(guild_id(1114).t["9Oq93m"]);
obj3.children = valueResult.map((user) => {
guildId = user;
return closure_1_16(MemberRow, {
guildId,
user,
isEditing,
2026-07-20 16:05:17 +00:00
onSelect() {
return importAll(user.id);
2026-07-20 16:05:17 +00:00
},
onDelete() {
return dependencyMap(user.id);
2026-07-20 16:05:17 +00:00
}
}, user.id);
2026-07-20 16:05:17 +00:00
});
obj2.children = closure_16(guild_id(5701).TableRowGroup, obj3);
tmp4 = closure_16(View, obj2);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp4;
2026-07-20 16:05:17 +00:00
}
const View = fn(17).View;
const isEveryoneRole = fn(2016).isEveryoneRole;
const Constants = fn(1074);
({ PermissionOverrideType: closure_14, ChannelSettingsSections: closure_15 } = Constants);
const jsxProd = fn(21);
2026-07-23 10:11:24 +00:00
({ jsx: closure_16, jsxs: closure_17 } = jsxProd);
const createStyles = fn(4574);
let obj2 = { tableRowGroupContainer: { marginBottom: nativeDefault.space.PX_16 }, tableContainer: null };
let obj3 = { marginBottom: nativeDefault.space.PX_16 };
obj2.tableContainer = { marginHorizontal: nativeDefault.space.PX_12 };
let closure_18 = createStyles.createStyles(obj2);
const size = fn(2);
let result = size.fileFinishedImporting("components_native/channel_settings/ChannelSettingsPermissionsOverview.tsx");
2026-07-20 16:05:17 +00:00
export default function ChannelSettingsPermissionsOverview(channelId) {
channelId = channelId.channelId;
2026-07-29 08:29:29 +00:00
let stateFromStores2;
isEditing = undefined;
noop = undefined;
2026-07-29 08:29:29 +00:00
let callback;
2026-07-20 16:05:17 +00:00
function handleClearPermissionOverwrite(arg0) {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
2026-07-20 16:05:17 +00:00
let tmp;
if (closure_4 != null) {
tmp = closure_4[arg0];
2026-07-20 16:05:17 +00:00
}
user = user.getUser(arg0);
2026-07-20 16:05:17 +00:00
if (null != tmp) {
let username = tmp.name;
2026-07-29 08:29:29 +00:00
} else if (user != null) {
2026-07-20 16:05:17 +00:00
username = user.username;
}
const obj2 = { title: null, body: null, cancelText: null, confirmText: null, onConfirm: null };
2026-09-02 09:53:35 +00:00
const intl = channelId(stateFromStores2[15]).intl;
obj2.title = intl.formatToPlainString(channelId(stateFromStores2[15]).t.txPV7k, { name: username });
2026-09-02 09:53:35 +00:00
const intl2 = channelId(stateFromStores2[15]).intl;
obj2.body = intl2.format(channelId(stateFromStores2[15]).t.xERCnZ, { name: username });
2026-09-02 09:53:35 +00:00
const intl3 = channelId(stateFromStores2[15]).intl;
obj2.cancelText = intl3.string(channelId(stateFromStores2[15]).t.gm1Vej);
2026-09-02 09:53:35 +00:00
const intl4 = channelId(stateFromStores2[15]).intl;
obj2.confirmText = intl4.string(channelId(stateFromStores2[15]).t.p89ACt);
obj2.onConfirm = function onConfirm() {
const result = ChannelActionCreatorsDefault.clearPermissionOverwrite(channelId, closure_0);
2026-07-20 16:05:17 +00:00
};
navigation(stateFromStores2[14]).show(obj2);
2026-07-20 16:05:17 +00:00
}
let tmp = closure_18();
const tmp2 = stateFromStores2;
const navigation = channelId(stateFromStores2[25]).useNavigation();
2026-09-02 09:53:35 +00:00
let obj = channelId(stateFromStores2[25]);
const items = [ChannelStore];
2026-07-20 16:05:17 +00:00
const items1 = [channelId];
const stateFromStores = channelId(stateFromStores2[29]).useStateFromStores(items, () => ChannelStore.getChannel(channelId), items1);
let obj2 = channelId(stateFromStores2[29]);
const appChannelBotUserId = channelId(stateFromStores2[18]).useAppChannelBotUserId(stateFromStores);
const obj3 = channelId(stateFromStores2[18]);
const items2 = [ChannelStore];
const stateFromStores1 = channelId(stateFromStores2[29]).useStateFromStores(items2, () => {
2026-07-20 16:05:17 +00:00
let parent_id;
2026-07-29 08:29:29 +00:00
if (stateFromStores != null) {
2026-07-20 16:05:17 +00:00
parent_id = stateFromStores.parent_id;
}
return ChannelStore.getChannel(parent_id);
2026-07-20 16:05:17 +00:00
});
const obj4 = channelId(stateFromStores2[29]);
const items3 = [GuildStore];
2026-09-02 09:53:35 +00:00
stateFromStores2 = channelId(stateFromStores2[29]).useStateFromStores(items3, () => {
2026-07-20 16:05:17 +00:00
let guild_id;
2026-07-29 08:29:29 +00:00
if (stateFromStores != null) {
2026-07-20 16:05:17 +00:00
guild_id = stateFromStores.guild_id;
}
return GuildStore.getGuild(guild_id);
2026-07-20 16:05:17 +00:00
});
2026-09-02 09:53:35 +00:00
const obj5 = channelId(stateFromStores2[29]);
const items4 = [GuildRoleStore];
_slicedToArray = channelId(stateFromStores2[29]).useStateFromStores(items4, () => {
2026-07-20 16:05:17 +00:00
let rolesSnapshot;
if (null != stateFromStores2) {
rolesSnapshot = GuildRoleStore.getRolesSnapshot(tmp.id);
2026-07-20 16:05:17 +00:00
}
return rolesSnapshot;
});
2026-09-02 09:53:35 +00:00
let areChannelsLockedResult = null != stateFromStores;
if (areChannelsLockedResult) {
areChannelsLockedResult = stateFromStores(tmp2[17]).areChannelsLocked(stateFromStores, stateFromStores1, appChannelBotUserId);
const obj7 = stateFromStores(tmp2[17]);
}
[isEditing, noop] = noop.useState(false);
callback = noop.useCallback(() => {
closure_6((arg0) => !arg0);
const result = DeprecatedLayoutAnimation.DeprecatedLayoutAnimation();
2026-07-20 16:05:17 +00:00
}, []);
const items5 = [navigation, isEditing, callback];
const layoutEffect = noop.useLayoutEffect(() => {
2026-07-20 16:05:17 +00:00
navigation.setOptions({
headerRight(arg0) {
const obj = {};
const merged = Object.assign(arg0);
obj.onPress = onPress;
const intl = channelId(stateFromStores2[15]).intl;
2026-07-20 16:05:17 +00:00
const string = intl.string;
const t = channelId(stateFromStores2[15]).t;
if (isEditing) {
2026-07-20 16:05:17 +00:00
let stringResult = string(t.i4jeWR);
} else {
stringResult = string(t.bt75uw);
}
2026-07-29 08:29:29 +00:00
obj.label = stringResult;
return closure_2_16(channelId(stateFromStores2[34]).HeaderTextButton, obj);
2026-07-20 16:05:17 +00:00
}
});
2026-09-02 09:53:35 +00:00
}, items5);
let tmp14 = null;
2026-07-20 16:05:17 +00:00
if (null != stateFromStores) {
2026-09-02 09:53:35 +00:00
tmp14 = null;
2026-07-20 16:05:17 +00:00
if (null != stateFromStores2) {
const obj8 = { style: tmp.tableContainer, children: null };
const obj9 = { channel: stateFromStores, category: stateFromStores1, isEditing, locked: areChannelsLockedResult };
const items6 = [closure_16(CategorySync, obj9), , , ];
const obj10 = { isEditing };
items6[1] = closure_16(AddPermission, obj10);
const obj11 = {
guild: stateFromStores2,
channel: stateFromStores,
isEditing,
onSelectRow(id) {
if (!first) {
const obj = { type: tmp, id };
navigation.push(constants2.PERMISSION_OVERRIDES, obj);
}
},
onDeleteRow(arg0) {
handleClearPermissionOverwrite(arg0);
}
2026-07-29 08:29:29 +00:00
};
items6[2] = closure_16(RoleOverwrites, obj11);
const obj12 = {
channel: stateFromStores,
isEditing,
onSelectRow(id) {
if (!first) {
const obj = { type: tmp, id };
navigation.push(constants2.PERMISSION_OVERRIDES, obj);
}
},
onDeleteRow(arg0) {
handleClearPermissionOverwrite(arg0);
}
2026-07-20 16:05:17 +00:00
};
items6[3] = closure_16(MemberOverwrites, obj12);
obj8.children = items6;
tmp14 = closure_17(callback, obj8);
2026-07-20 16:05:17 +00:00
}
}
2026-09-02 09:53:35 +00:00
return tmp14;
2026-07-20 16:05:17 +00:00
};