Files
discord-decomp/modules/user_profile/native/BotUserProfileContent.tsx
T
2026-11-01 12:12:55 +02:00

161 lines
9.0 KiB
TypeScript

// Metro module 11963 (f11964).
import { memo, useMemo } from "react";
import { View } from "react-native";
import UserStore from "../../../stores/UserStore";
import { PROFILE_CONTENT_BOTTOM_PADDING, PROFILE_CONTENT_WITHOUT_STATUS_TOP_PADDING } from "./Constants";
import { ACTION_SHEET_MAX_WIDTH } from "../../action_sheet/native/ActionSheetConstants";
import UserProfileSharedStyles from "./UserProfileSharedStyles";
import useUserProfileBannerHeight from "../hooks/native/useUserProfileBannerHeight";
import useUserProfileOverscrollStyles from "./useUserProfileOverscrollStyles";
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
import { useUserProfileAnalyticsContext } from "../UserProfileAnalyticsContext";
import { useStateFromStores } from "../../../_bundle/Module589";
import NicknameUtils from "../../../utils/NicknameUtils";
import UserUtils from "../../../utils/UserUtils";
import { useSubscribeGuildMembers } from "../../../lib/guild/subscribeGuildMembers";
import useBadges from "../hooks/useBadges";
import useCustomStatusActivityForUser from "../../custom_status/utils/useCustomStatusActivityForUser";
import useProfileTheme from "../hooks/useProfileTheme";
import { useUserProfileColors } from "../hooks/native/useUserProfileColors";
import { copy } from "../../../utils/ClipboardUtils.native";
import { presentUsernameCopied, presentUserPronouns } from "../../toast/native/ToastUtils";
import UserProfileOverscrollBanner from "./UserProfileOverscrollBanner";
import ReanimatedRexport from "../../reanimated/ReanimatedRexport";
import BotUserProfileOverflowMenu from "./BotUserProfileOverflowMenu";
import { OpenableUserProfileAvatar } from "./UserProfileAvatar";
import UserProfileCustomStatusBubble from "./UserProfileCustomStatusBubble";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import UserProfilePrimaryInfo from "./UserProfilePrimaryInfo";
import { intl, t } from "../../../intl/index.native";
import UserProfileMutualGuilds from "./UserProfileMutualGuilds";
import UserProfileTextButtonGroup from "./UserProfileTextButtonGroup";
import { canInstallApplication } from "../../applications/utils/ApplicationInstallUtils";
import AddOrOpenAppButton from "./AddOrOpenAppButton";
import { Button } from "../../../design/components/Button/native/Button.native";
import { ChatIcon } from "../../../design/components/Icon/native/redesign/generated/ChatIcon";
import Module712 from "../../../_bundle/Module712";
import ModalActionCreators from "../../../actions/ModalActionCreators";
import ChannelActionCreators from "../../../actions/ChannelActionCreators";
import UserProfileActivity from "./UserProfileActivity";
import UserProfileAboutMeCard from "./UserProfileAboutMeCard";
import UserProfileRolesCard from "./UserProfileRolesCard";
import UserProfileModeratorActions from "./UserProfileModeratorActions";
import UserProfileNote from "./UserProfileNote";
const r34 = memo(function BotUserProfileContent(props) {
let userTag, guild_id;
const { user, channel, displayProfile, showUserProfileActionSheet, disableMessage, scrollPosition } = props;
userTag = void 0;
guild_id = void 0;
const styles = UserProfileSharedStyles();
const userProfileBannerHeight = useUserProfileBannerHeight(ACTION_SHEET_MAX_WIDTH);
const styles2 = useUserProfileOverscrollStyles({
scrollPosition,
bannerHeight: userProfileBannerHeight
});
const { bannerAnimatedStyle, bannerImageAnimatedStyle, contentAnimatedStyle, blurAnimatedProps, showBlur } = styles2;
const bottom = useSafeAreaInsets_native().bottom;
const trackUserProfileAction = useUserProfileAnalyticsContext().trackUserProfileAction;
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
const name = NicknameUtils.useName(displayProfile?.guildId, channel?.id, user);
userTag = UserUtils.useUserTag(user);
const application = displayProfile?.application;
guild_id = channel?.guild_id;
useSubscribeGuildMembers(useMemo(() => {
let r6;
if (guild_id != null && user != null) {
const r2 = {};
r2[guild_id] = [user.id];
r6 = r2;
} else {
r6 = {};
}
return r6;
}, [guild_id, user]), "BotUserProfileContent");
const badges = useBadges(displayProfile);
const customStatusActivityForUser = useCustomStatusActivityForUser(user.id);
const profileTheme = useProfileTheme({
user,
displayProfile
});
const { theme, primaryColor } = profileTheme;
const userProfileColors = useUserProfileColors({
theme,
primaryColor,
secondaryColor: profileTheme.secondaryColor
});
const { containerBackground, avatarBackground, statusBackground } = userProfileColors;
if (user != null && stateFromStores != null) {
const r101 = [<UserProfileOverscrollBanner user={user} displayProfile={displayProfile} bannerHeight={userProfileBannerHeight} bannerAnimatedStyle={bannerAnimatedStyle} bannerImageAnimatedStyle={bannerImageAnimatedStyle} blurAnimatedProps={blurAnimatedProps} showBlur={showBlur} />, <ReanimatedRexport.View style={[styles.bannerButtons, bannerAnimatedStyle]}>
<BotUserProfileOverflowMenu user={user} application={application} channel={channel} />
</ReanimatedRexport.View>, ,];
let guildId = displayProfile?.guildId;
if (guildId == null) {
guildId = void 0;
}
const r125 = [<OpenableUserProfileAvatar user={user} guildId={guildId} backgroundColor={avatarBackground} statusStyle={{
backgroundColor: statusBackground
}} />, ,];
const style = [styles.profileContentWrapper, styles.profileContent, {
paddingTop: customStatusActivityForUser != null ? 0 : PROFILE_CONTENT_WITHOUT_STATUS_TOP_PADDING,
paddingBottom: bottom + PROFILE_CONTENT_BOTTOM_PADDING
}];
const r144 = [<UserProfileCustomStatusBubble customStatusActivity={customStatusActivityForUser} hasCustomProfileTheme={primaryColor != null} onPressTruncatedStatus={function onPressTruncatedStatus() {
ActionSheetActionCreators.openLazy(import("./UserProfileCustomStatusActionSheet"), "UserProfileCustomStatusActionSheet", {
user,
guildId: guild_id,
channelId: channel?.id
}, "stack");
}} style={styles.customStatusBubble} emojiOnlyStyle={styles.emojiOnlyCustomStatusBubble} />, , ,];
const pronouns = displayProfile?.pronouns;
const handleCopyUsername = function handleCopyUsername() {
trackUserProfileAction({
action: "COPY_USERNAME"
});
copy(userTag);
presentUsernameCopied();
};
r144[1] = <View style={styles.primaryInfo}>
<UserProfilePrimaryInfo user={user} guildId={guild_id} displayName={name} pronouns={pronouns} badges={badges} badgeContainerBackground={containerBackground} displayNameAccessibilityHint={intl.string(t.y5MwJy)} onPressDisplayName={handleCopyUsername} onPressUserTag={handleCopyUsername} onPressPronouns={function handlePressPronouns() {
trackUserProfileAction({
action: "PRESS_PRONOUNS"
});
presentUserPronouns();
}} showBadgeToastOnPress />
<UserProfileMutualGuilds user={user} />
<UserProfileTextButtonGroup style={styles.primaryButtons} maxWidth={ACTION_SHEET_MAX_WIDTH} primaryButton={application != null ? canInstallApplication(application) ? <AddOrOpenAppButton application={application} botUserId={user.id} channel={channel == null ? void 0 : channel} guildId={guild_id == null ? void 0 : guild_id} /> : void 0 : void 0} secondaryButton={<Button icon={<ChatIcon size="sm" color={Module712.colors.CONTROL_SECONDARY_TEXT_DEFAULT} />} text={intl.string(t.zROXEV)} variant="secondary" disabled={disableMessage} grow accessibilityHint={intl.formatToPlainString(t.zFfSFQ, {
name: UserUtils.getName(user)
})} onPress={() => {
trackUserProfileAction({
action: "SEND_MESSAGE"
});
ActionSheetActionCreators.hideActionSheet();
ModalActionCreators.popAll();
ChannelActionCreators.openPrivateChannel({
recipientIds: user.id
});
}} />} />
</View>;
const r225 = stateFromStores == null;
let r226 = null;
if (!r225) {
const style2 = [styles.card, {
backgroundColor: containerBackground
}];
r226 = <View style={styles.cards}>
<UserProfileActivity user={user} currentUser={stateFromStores} guildId={guild_id} style={style2} />
<UserProfileAboutMeCard userId={user.id} displayProfile={displayProfile} channel={channel} style={style2} />
{guild_id != null && <>
{[<UserProfileRolesCard userId={user.id} guildId={guild_id} style={style2} />, <UserProfileModeratorActions user={user} currentUser={stateFromStores} guildId={guild_id} channelId={channel?.id} showUserProfile={showUserProfileActionSheet} style={style2} />]}
</>}
<UserProfileNote userId={user.id} style={style2} onBack={showUserProfileActionSheet} />
</View>;
}
r144[2] = r226;
r125[1] = <View style={style}>{r144}</View>;
r101[2] = <ReanimatedRexport.View style={contentAnimatedStyle}>{r125}</ReanimatedRexport.View>;
return <>{r101}</>;
}
return null;
});
export default r34;