271 lines
14 KiB
TypeScript
271 lines
14 KiB
TypeScript
// Metro module 11873 (f11874).
|
|
import { isValidElement, memo } from "react";
|
|
import { View } from "react-native";
|
|
import GatewayConnectionStore from "../../../gateway/GatewayConnectionStore";
|
|
import { THREAD_CHANNEL_TYPES } from "../../../../records/ChannelRecord";
|
|
import ChannelStore from "../../../../stores/ChannelStore";
|
|
import GuildStore from "../../../../stores/GuildStore";
|
|
import PresenceStore from "../../../../stores/PresenceStore";
|
|
import RelationshipStore from "../../../../stores/RelationshipStore";
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import { ChannelTypes, Fonts } from "../../../../Constants";
|
|
import { StaticChannelRoute } from "../../../channel/ChannelConstants";
|
|
import { ContentDismissActionType, DismissibleContentGroupName } from "../../../dismissible_content/DismissibleContentConstants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import TextStyles from "../../../rebrand/native/TextStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { useStateFromStores, useStateFromStoresObject } from "../../../../_bundle/Module589";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { getThreadChannelIcon, getChannelIconWithGuild, getChannelIcon } from "../../../../utils/native/ChannelUtils";
|
|
import { computeChannelName } from "../../../channel/useChannelName";
|
|
import ActivityStatus from "../../../activity_status/native/ActivityStatus";
|
|
import { useSelectedSpecialNavigationPath, SpecialNavigationPath } from "../NavigationPathUtils";
|
|
import useIsViewingPremiumMemberships from "../../../guild_role_subscriptions/useIsViewingPremiumMemberships";
|
|
import { Icon, LegacyText, Status, StatusSizes } from "../../../../design/void/native";
|
|
import Module10140 from "../../../../_bundle/Module10140";
|
|
import Module11876 from "../../../../_bundle/Module11876";
|
|
import FastImage from "../../../../components_native/common/FastImage";
|
|
import Module10138 from "../../../../_bundle/Module10138";
|
|
import { shouldNSFWGateGuild } from "../../../age_gate/native/AgeGateUtils";
|
|
import { PressableOpacity } from "../../../../design/void/Pressables/native/Pressables";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import UserUtils from "../../../../utils/UserUtils";
|
|
import isStreaming from "../../../activities/utils/isStreaming";
|
|
import TouchableHitBox from "../../../../design/void/TouchableHitBox/native/TouchableHitBox";
|
|
import { UNSAFE_markDismissibleContentAsDismissed } from "../../../dismissible_content/DismissibleContentUnsafeUtils";
|
|
import { DismissibleContent } from "../../../../_bundle/Module1358";
|
|
import SelectedDismissibleContent from "../../../dismissible_content/native/SelectedDismissibleContent";
|
|
import ActivitiesPrivateChannelCallTooltip from "../../../activities/native/ActivitiesPrivateChannelCallTooltip";
|
|
let useStyles, ChannelTitleWrapper, ParentChannelSubTitle, DMChannelName, ConnectedStatus;
|
|
const ChannelTitleContent = function ChannelTitleContent(props) {
|
|
const { title, icon, titleSuffix, subTitle, accessibleTitle } = props;
|
|
const styles = useStyles();
|
|
return <View style={styles.flexRow}>
|
|
{icon != null ? isValidElement(icon) ? icon : <Icon size={Icon.Sizes.CUSTOM} source={icon} style={styles.channelIcon} color={styles.channelIconColor.color} /> : null}
|
|
<View style={styles.channelTextContainer}>
|
|
<View style={styles.flexRow}>
|
|
{isValidElement(title) ? title : <View style={styles.channelNameContainer}>
|
|
<Text style={styles.channelName} lineClamp={1} variant="heading-md/bold" color="mobile-text-heading-primary" accessibilityLabel={accessibleTitle} maxFontSizeMultiplier={1} accessibilityRole="header">{title}</Text>
|
|
</View>}
|
|
{titleSuffix}
|
|
</View>
|
|
{subTitle}
|
|
</View>
|
|
</View>;
|
|
};
|
|
ParentChannelSubTitle = function ParentChannelSubTitle(props) {
|
|
const parentChannel = props.parentChannel;
|
|
return <Text lineClamp={1} style={useStyles().navbarTitleSecondaryText} accessibilityLabel={intl.formatToPlainString(t.BjYvHO, {
|
|
channelName: computeChannelName(parentChannel, UserStore, RelationshipStore)
|
|
})} maxFontSizeMultiplier={1} variant="text-xs/medium" color="text-muted">
|
|
{computeChannelName(parentChannel, UserStore, RelationshipStore, true)}
|
|
</Text>;
|
|
};
|
|
DMChannelName = function DMChannelName(props) {
|
|
const { userId, style } = props;
|
|
const stateFromStores2 = useStateFromStores([UserStore, RelationshipStore], () => {
|
|
let r7 = RelationshipStore.getNickname(userId);
|
|
const user = UserStore.getUser(userId);
|
|
if (r7 == null) {
|
|
r7 = UserUtils.getName(user);
|
|
}
|
|
if (r7 == null) {
|
|
r7 = "";
|
|
}
|
|
return r7;
|
|
}, [userId]);
|
|
return <LegacyText numberOfLines={1} style={style} accessibilityLabel={intl.formatToPlainString(t.fYqXVY, {
|
|
channelName: stateFromStores2
|
|
})} maxFontSizeMultiplier={1} accessibilityRole="header">{stateFromStores2}</LegacyText>;
|
|
};
|
|
ConnectedStatus = function ConnectedStatus(props) {
|
|
const { style, userId: userId2 } = props;
|
|
const stateFromStoresObject = useStateFromStoresObject([PresenceStore], () => ({
|
|
status: PresenceStore.getStatus(userId2),
|
|
isMobileOnline: PresenceStore.isMobileOnline(userId2),
|
|
isVROnline: PresenceStore.isVROnline(userId2),
|
|
streaming: isStreaming(PresenceStore.getActivities(userId2))
|
|
}));
|
|
return <Status isMobileOnline={stateFromStoresObject.isMobileOnline} isVROnline={stateFromStoresObject.isVROnline} status={stateFromStoresObject.status} streaming={stateFromStoresObject.streaming} size={StatusSizes.SMALL} style={style} />;
|
|
};
|
|
useStyles = createStyles({
|
|
navbarTitleContainer: {
|
|
height: "100%",
|
|
flex: 1,
|
|
flexDirection: "row",
|
|
alignItems: "center"
|
|
},
|
|
navbarTitlePrimaryText: {
|
|
...TextStyles(Fonts.DISPLAY_SEMIBOLD, Module712.colors.MOBILE_TEXT_HEADING_PRIMARY, 18),
|
|
flexShrink: 1
|
|
},
|
|
navbarTitleSecondaryText: {
|
|
fontSize: 12,
|
|
lineHeight: 16,
|
|
color: Module712.colors.TEXT_MUTED,
|
|
marginTop: -4
|
|
},
|
|
channelIcon: {
|
|
height: 18,
|
|
width: 18,
|
|
marginRight: 8
|
|
},
|
|
channelIconColor: {
|
|
color: Module712.colors.CHANNEL_ICON
|
|
},
|
|
homeIcon: {
|
|
height: 20,
|
|
width: 20,
|
|
tintColor: Module712.colors.TEXT_MUTED,
|
|
marginTop: 0,
|
|
marginRight: 8
|
|
},
|
|
premiumIcon: {
|
|
marginRight: 4
|
|
},
|
|
status: {
|
|
marginLeft: 1,
|
|
marginTop: 4
|
|
},
|
|
channelTextContainer: {
|
|
flex: 1,
|
|
flexGrow: 1
|
|
},
|
|
channelNameContainer: {
|
|
flexGrow: 1
|
|
},
|
|
channelName: {
|
|
textAlign: "left"
|
|
},
|
|
flexRow: {
|
|
flexDirection: "row",
|
|
alignItems: "center"
|
|
}
|
|
});
|
|
const r96 = memo(function({ onPressTitle, channelId, guildId, threadDraft, style }) {
|
|
let stateFromStores;
|
|
stateFromStores = void 0;
|
|
const styles = useStyles();
|
|
const stateFromStores3 = useStateFromStores([GatewayConnectionStore], () => GatewayConnectionStore.isConnected());
|
|
stateFromStores = useStateFromStores([ChannelStore], () => channelId !== StaticChannelRoute.GUILD_HOME ? channelId !== StaticChannelRoute.MEMBER_SAFETY ? ChannelStore.getChannel(channelId) : null : null);
|
|
const stateFromStores4 = useStateFromStores([GuildStore], () => GuildStore.getGuild(stateFromStores == null ? void 0 : stateFromStores.getGuildId()));
|
|
const stateFromStores2 = useStateFromStores([ChannelStore], () => threadDraft != null && threadDraft.parentChannelId != null ? ChannelStore.getChannel(threadDraft.parentChannelId) : stateFromStores != null ? stateFromStores.parent_id != null ? THREAD_CHANNEL_TYPES.has(stateFromStores.type) ? ChannelStore.getChannel(stateFromStores.parent_id) : null : null : null, [stateFromStores, threadDraft]);
|
|
const selectedSpecialNavigationPath = useSelectedSpecialNavigationPath();
|
|
const isViewingPremiumMemberships = useIsViewingPremiumMemberships();
|
|
const title2 = stateFromStores3 ? intl.string(t.ai6Lbr) : intl.string(t.ZTNur7);
|
|
if (selectedSpecialNavigationPath === SpecialNavigationPath.FRIENDS) {
|
|
return <ChannelTitleWrapper style={style}>
|
|
<ChannelTitleContent title={intl.string(t.TdEu5X)} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
if (channelId === StaticChannelRoute.GUILD_HOME) {
|
|
const icon3 = <Icon size={Icon.Sizes.CUSTOM} source={Module10140} style={styles.homeIcon} />;
|
|
return <ChannelTitleWrapper onPressTitle={onPressTitle} style={style}>
|
|
<ChannelTitleContent title={intl.string(t.Ym2Ri6)} icon={icon3} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
if (channelId === StaticChannelRoute.MEMBER_SAFETY) {
|
|
const icon2 = <Icon size={Icon.Sizes.CUSTOM} source={Module11876} style={styles.homeIcon} />;
|
|
return <ChannelTitleWrapper onPressTitle={onPressTitle} style={style}>
|
|
<ChannelTitleContent title={intl.string(t["9Oq93m"])} icon={icon2} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
if (isViewingPremiumMemberships) {
|
|
const icon = <FastImage source={Module10138} style={styles.premiumIcon} />;
|
|
return <ChannelTitleWrapper style={style}>
|
|
<ChannelTitleContent title={intl.string(t["KzCF/6"])} icon={icon} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
if (threadDraft != null && !(stateFromStores == null ? void 0 : stateFromStores.isForumLikeChannel())) {
|
|
const title = threadDraft.name != null && threadDraft.name.length > 0 ? threadDraft.name : intl.string(t["4WNcpu"]);
|
|
const threadChannelIcon = getThreadChannelIcon(threadDraft.isPrivate ? ChannelTypes.PRIVATE_THREAD : ChannelTypes.PUBLIC_THREAD);
|
|
return <ChannelTitleWrapper style={style}>
|
|
<ChannelTitleContent title={title} accessibleTitle={intl.formatToPlainString(t["OkzL+Q"], {
|
|
channelName: title
|
|
})} icon={threadChannelIcon} subTitle={stateFromStores2 != null && <ParentChannelSubTitle parentChannel={stateFromStores2} />} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
if (shouldNSFWGateGuild(guildId)) {
|
|
return <ChannelTitleWrapper style={style}>
|
|
<ChannelTitleContent title={intl.string(t.HbPHt1)} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
if (stateFromStores == null) {
|
|
return <ChannelTitleWrapper style={style}>
|
|
<ChannelTitleContent title={title2} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
const title3 = computeChannelName(stateFromStores, UserStore, RelationshipStore);
|
|
const channelIconWithGuild = getChannelIconWithGuild(stateFromStores, stateFromStores4);
|
|
if (stateFromStores.isDM()) {
|
|
const recipientId = stateFromStores.getRecipientId();
|
|
return <ChannelTitleWrapper onPressTitle={onPressTitle} style={style}>
|
|
<ChannelTitleContent title={<DMChannelName userId={recipientId} style={styles.navbarTitlePrimaryText} />} icon={channelIconWithGuild} titleSuffix={stateFromStores.isSystemDM() ? null : <ConnectedStatus userId={recipientId} style={styles.status} />} subTitle={<ActivityStatus userId={recipientId} guildId={stateFromStores?.guild_id} />} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
if (stateFromStores.isThread()) {
|
|
return <ChannelTitleWrapper onPressTitle={onPressTitle} style={style}>
|
|
<ChannelTitleContent title={title3} accessibleTitle={intl.formatToPlainString(t["OkzL+Q"], {
|
|
channelName: title3
|
|
})} icon={channelIconWithGuild} subTitle={stateFromStores2 != null && <ParentChannelSubTitle parentChannel={stateFromStores2} />} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
return <ChannelTitleWrapper onPressTitle={onPressTitle} style={style}>
|
|
<ChannelTitleContent title={title3} accessibleTitle={intl.formatToPlainString(t.UbNmGc, {
|
|
channelName: title3
|
|
})} icon={channelIconWithGuild} />
|
|
</ChannelTitleWrapper>;
|
|
});
|
|
ChannelTitleWrapper = (props) => {
|
|
const { children: children2, onPressTitle, style } = props;
|
|
const styles = useStyles();
|
|
return onPressTitle == null ? <View style={[styles.navbarTitleContainer, style]}>{children2}</View> : <PressableOpacity style={[styles.navbarTitleContainer, style]} accessibilityRole="header" onPress={onPressTitle} onAccessibilityTap={() => null}>{children2}</PressableOpacity>;
|
|
};
|
|
export function ChannelTitleWithoutRoute(props) {
|
|
const { onPressTitle, channelId: channelId2 } = props;
|
|
const styles = useStyles();
|
|
const stateFromStores2 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId2));
|
|
const r11 = useStateFromStores([GatewayConnectionStore], () => GatewayConnectionStore.isConnected()) ? intl.string(t.ai6Lbr) : intl.string(t.ZTNur7);
|
|
const icon = stateFromStores2 != null ? getChannelIcon(stateFromStores2) : null;
|
|
let title = stateFromStores2 != null ? computeChannelName(stateFromStores2, UserStore, RelationshipStore) : null;
|
|
if (stateFromStores2 == null ? void 0 : stateFromStores2.isDM()) {
|
|
const recipientId = stateFromStores2.getRecipientId();
|
|
return <ChannelTitleWrapper onPressTitle={onPressTitle}>
|
|
<ChannelTitleContent title={<DMChannelName userId={recipientId} style={styles.navbarTitlePrimaryText} />} icon={icon} titleSuffix={stateFromStores2.isSystemDM() ? null : <ConnectedStatus userId={recipientId} style={styles.status} />} subTitle={<ActivityStatus userId={recipientId} guildId={stateFromStores2.guild_id} />} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
if (title == null) {
|
|
title = r11;
|
|
}
|
|
return <ChannelTitleWrapper onPressTitle={onPressTitle}>
|
|
<ChannelTitleContent title={title} icon={icon} />
|
|
</ChannelTitleWrapper>;
|
|
}
|
|
export { r96 as ChannelTitle };
|
|
export function ChannelButtons(props) {
|
|
const buttons = props.buttons;
|
|
return <View style={props.style}>
|
|
{buttons == null ? void 0 : buttons.map((button, index) => {
|
|
let onPress2 = button.onPress;
|
|
const onPress = onPress2;
|
|
const { onLongPress, source, color, style, accessibilityLabel, children: children2, disabled, hasActivitiesPrivateChannelTooltip } = button;
|
|
if (hasActivitiesPrivateChannelTooltip) {
|
|
onPress2 = (a0) => {
|
|
if (onPress != null) {
|
|
onPress(a0);
|
|
}
|
|
UNSAFE_markDismissibleContentAsDismissed(DismissibleContent.ACTIVITY_GDM_CALL_TOOLTIP, {
|
|
dismissAction: ContentDismissActionType.AUTO
|
|
});
|
|
};
|
|
}
|
|
return <View key={index}>
|
|
<TouchableHitBox accessibilityRole="button" accessibilityLabel={accessibilityLabel} color={color} source={source} onPress={onPress2} onLongPress={onLongPress} disabled={disabled} style={style}>{children2}</TouchableHitBox>
|
|
{hasActivitiesPrivateChannelTooltip ? <SelectedDismissibleContent contentTypes={[DismissibleContent.ACTIVITY_GDM_CALL_TOOLTIP]} groupName={DismissibleContentGroupName.CHANNEL_HEADER_CALL_BUTTON_TOOLTIPS}>
|
|
{({ visibleContent, markAsDismissed }) => visibleContent === DismissibleContent.ACTIVITY_GDM_CALL_TOOLTIP ? <ActivitiesPrivateChannelCallTooltip onClosePress={() => markAsDismissed(ContentDismissActionType.UNKNOWN)} /> : null}
|
|
</SelectedDismissibleContent> : null}
|
|
</View>;
|
|
})}
|
|
</View>;
|
|
}
|