Files
discord-decomp/modules/channel_permissions/native/components/ChannelAccessInfo.tsx
T
2026-11-01 12:12:55 +02:00

130 lines
4.6 KiB
TypeScript

// Metro module 11563 (f11564).
import { View } from "react-native";
import { isGuildOwner } from "../../../../records/GuildRecord";
import GuildMemberStore from "../../../../stores/GuildMemberStore";
import GuildRoleStore from "../../../../stores/GuildRoleStore";
import { Fragment, jsx } from "react/jsx-runtime";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import { intl, t } from "../../../../intl/index.native";
import { useStateFromStoresArray } from "../../../../_bundle/Module589";
import { getExistingRoles, getExistingMembers } from "../../ChannelPermissionsUtils";
import { assertNever } from "../../../../utils/GlobalUtils";
import { Text } from "../../../../design/components/Text/native/Text";
import { PressableOpacity } from "../../../../design/void/Pressables/native/Pressables";
import { openChannelMembersActionSheet } from "../ChannelPermissionsUtils";
import { Avatar, AvatarSizes, Icon } from "../../../../design/void/native";
import Module11562 from "../../../../_bundle/Module11562";
import { GroupIcon } from "../../../../design/components/Icon/native/redesign/generated/GroupIcon";
import Module8288 from "../../../../_bundle/Module8288";
import { ShieldUserIcon } from "../../../../design/components/Icon/native/redesign/generated/ShieldUserIcon";
import Module10737 from "../../../../_bundle/Module10737";
const count = 100;
const useStyles = createStyles({
section: {
alignItems: "center",
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
borderRadius: Module712.radii.sm,
color: Module712.colors.TEXT_DEFAULT,
flexDirection: "row",
marginBottom: 8,
marginTop: 8,
padding: 16
},
sectionContent: {
alignItems: "center",
flexDirection: "row",
flexGrow: 1
},
avatar: {
marginRight: 8
},
labelDetail: {
marginRight: 12
},
sectionIcon: {
marginRight: 6
}
});
let c7887_13 = {
MEMBERS: 0,
0: "MEMBERS",
ROLES: 1,
1: "ROLES"
};
export default function ChannelAccessInfo(props) {
let props3;
const { guild, channel } = props;
const styles = useStyles();
const accessibilityLabel = intl.string(t.li1wKf);
const stateFromStoresArray = useStateFromStoresArray([GuildRoleStore], () => getExistingRoles(guild, GuildRoleStore.getSortedRoles(guild.id), channel, channel.accessPermissions), [guild, channel]);
const existingMembers = getExistingMembers(GuildMemberStore.getMemberIds(guild?.id), channel, guild, channel.accessPermissions);
const user = stateFromStoresArray.length === 0 && existingMembers.length === 1 && isGuildOwner(guild, existingMembers[0]) ? existingMembers[0] : null;
const r64 = [<Text variant="eyebrow">{accessibilityLabel}</Text>, ,];
const props2 = {
accessibilityLabel,
accessibilityRole: "button",
onPress: function onPress() {
openChannelMembersActionSheet(channel.id, channel.guild_id);
},
style: styles.section,
children: null
};
if (user != null) {
props3 = {
children: [<Avatar style={styles.avatar} user={user} guildId={guild.id} size={AvatarSizes.XSMALL} />, <View>
<Text variant="text-sm/semibold">{user.tag}</Text>
<Text variant="text-xs/medium">
{intl.string(t.rt0ERW)}
</Text>
</View>]
};
} else {
const renderCounts = function renderCounts(a0, a1, a2, a3) {
let r10;
if (a1 === 0) {
return null;
}
if (c7887_13.MEMBERS === a0) {
r10 = a1 > count ? intl.formatToPlainString(t.PR5l07, {
count
}) : intl.formatToPlainString(t.bu5sya, {
count: a1
});
} else if (c7887_13.ROLES === a0) {
r10 = a1 > count ? intl.formatToPlainString(t["+OYnFQ"], {
count
}) : intl.formatToPlainString(t.T2BEtm, {
count: a1
});
} else {
assertNever(a0);
r10 = void 0;
}
return <>
{jsx(a3, {
size: "sm",
style: styles.sectionIcon
})}
<Text style={styles.labelDetail} variant="text-sm/medium">{r10}</Text>
</>;
};
const MEMBERS = c7887_13.MEMBERS;
const length = existingMembers.length;
Module11562;
const children = [renderCounts(MEMBERS, length, 0, GroupIcon), ,];
const ROLES = c7887_13.ROLES;
const length2 = stateFromStoresArray.length;
Module8288;
children[1] = renderCounts(ROLES, length2, 0, ShieldUserIcon);
props3 = {
children
};
}
props2.children = [<View style={styles.sectionContent}>
<Fragment {...props3} />
</View>, <Icon source={Module10737} size={Icon.Sizes.SMALL} />];
r64[1] = <PressableOpacity {...props2} />;
return <>{r64}</>;
};