133 lines
5.2 KiB
TypeScript
133 lines
5.2 KiB
TypeScript
// Metro module 15855 (f15856).
|
|
import { memo } from "react";
|
|
import { View } from "react-native";
|
|
import ChannelStore from "../../../../stores/ChannelStore";
|
|
import GuildStore from "../../../../stores/GuildStore";
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import { InviteSendStates } from "../../../instant_invite/Constants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import useChannelName from "../../../channel/useChannelName";
|
|
import { RowTypes } from "../../../../utils/InstantInviteUtils";
|
|
import { PressableOpacity } from "../../../../design/void/Pressables/native/Pressables";
|
|
import { Avatar, AvatarSizes } from "../../../../design/void/native";
|
|
import DiscordTag from "../../../user_profile/native/DiscordTag";
|
|
import UserUtils from "../../../../utils/UserUtils";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import AvatarUtils from "../../../../utils/AvatarUtils";
|
|
import { getAcronym } from "../../../../utils/StringUtils";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { TableRow } from "../../../../design/components/TableRow/native/TableRow.native";
|
|
import InviteButton from "../../../instant_invite/native/components/InviteButton";
|
|
const useStyles = createStyles({
|
|
acronym: {
|
|
width: 32,
|
|
height: 32,
|
|
borderRadius: Module712.radii.lg,
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
overflow: "hidden",
|
|
marginTop: 0,
|
|
marginRight: 10,
|
|
borderColor: Module712.colors.BORDER_MUTED,
|
|
borderStyle: "solid",
|
|
borderWidth: 2
|
|
}
|
|
});
|
|
const r50 = memo(function ActivityInviteSheetRow(props) {
|
|
let accessibilityActions, end, error, icon, isSubmitting, label, onAccessibilityAction, sendState, start;
|
|
let onInviteSent, onPressAvatar, row, id;
|
|
L31: {
|
|
end = props.end;
|
|
error = props.error;
|
|
isSubmitting = props.isSubmitting;
|
|
onInviteSent = props.onInviteSent;
|
|
onPressAvatar = props.onPressAvatar;
|
|
row = props.row;
|
|
sendState = props.sendState;
|
|
start = props.start;
|
|
id = void 0;
|
|
const styles = useStyles();
|
|
id = row.item.id;
|
|
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(id));
|
|
let r40 = useChannelName(stateFromStores);
|
|
const type = row.type;
|
|
if (RowTypes.DM !== type && RowTypes.FRIEND !== type) {
|
|
if (RowTypes.GROUP_DM === type) {
|
|
const r104 = stateFromStores != null ? <Avatar source={AvatarUtils.makeSource(AvatarUtils.getChannelIconURL({
|
|
id: stateFromStores.id,
|
|
icon: stateFromStores.icon,
|
|
applicationId: stateFromStores.application_id,
|
|
size: 32
|
|
}))} size={AvatarSizes.REFRESH_MEDIUM_32} /> : null;
|
|
if (r40 == null) {
|
|
r40 = "";
|
|
}
|
|
label = r40;
|
|
onAccessibilityAction = void 0;
|
|
accessibilityActions = void 0;
|
|
icon = r104;
|
|
break L31;
|
|
}
|
|
if (RowTypes.CHANNEL === type) {
|
|
const r25 = stateFromStores?.guild_id != null ? GuildStore.getGuild(stateFromStores.guild_id) : void 0;
|
|
if (r25 == null) {
|
|
return null;
|
|
}
|
|
icon = r25.icon != null ? <Avatar source={AvatarUtils.makeSource(AvatarUtils.getGuildIconURL({
|
|
id: r25.id,
|
|
icon: r25.icon,
|
|
size: 32
|
|
}))} size={AvatarSizes.REFRESH_MEDIUM_32} /> : <View style={styles.acronym}>
|
|
<Text variant="text-sm/bold">
|
|
{getAcronym(r25.name)}
|
|
</Text>
|
|
</View>;
|
|
label = r40 == null ? "" : `#${r40}`;
|
|
onAccessibilityAction = void 0;
|
|
accessibilityActions = void 0;
|
|
break L31;
|
|
}
|
|
return null;
|
|
}
|
|
const user = UserStore.getUser(id);
|
|
let source = user == null ? void 0 : user.getAvatarSource(void 0);
|
|
if (source == null) {
|
|
source = null;
|
|
}
|
|
const r146 = <PressableOpacity importantForAccessibility="no-hide-descendants" accessibilityElementsHidden onPress={(event) => {
|
|
event.stopPropagation();
|
|
if (onPressAvatar != null) {
|
|
onPressAvatar(id);
|
|
}
|
|
}} style={{
|
|
padding: 8,
|
|
margin: -8
|
|
}}>
|
|
<Avatar source={source} size={AvatarSizes.REFRESH_MEDIUM_32} />
|
|
</PressableOpacity>;
|
|
const r154 = <DiscordTag nick={UserUtils.getGlobalName(user)} user={user} />;
|
|
const r156 = onPressAvatar != null ? [{
|
|
name: "viewProfile",
|
|
label: intl.formatToPlainString(t.uCenkh, {
|
|
username: user?.tag
|
|
})
|
|
}] : void 0;
|
|
onAccessibilityAction = (a0) => {
|
|
if (a0.nativeEvent.actionName === "viewProfile" && onPressAvatar !== null && onPressAvatar != null) {
|
|
onPressAvatar(id);
|
|
}
|
|
};
|
|
accessibilityActions = r156;
|
|
label = r154;
|
|
icon = r146;
|
|
}
|
|
const handlePress = function handlePress() {
|
|
onInviteSent(row);
|
|
};
|
|
return <TableRow start={start} end={end} icon={icon} label={label} trailing={<InviteButton sendState={sendState} onPressSend={handlePress} />} onPress={handlePress} disabled={error != null || isSubmitting || sendState === InviteSendStates.SENT} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} />;
|
|
});
|
|
export default r50;
|