127 lines
5.7 KiB
TypeScript
127 lines
5.7 KiB
TypeScript
// Metro module 15192 (f15193).
|
|
import NewChannelsStore from "../../recent_channels/NewChannelsStore";
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import PermissionStore from "../../../stores/PermissionStore";
|
|
import ReadStateStore from "../../../stores/ReadStateStore";
|
|
import VoiceStateStore from "../../../stores/VoiceStateStore";
|
|
import { GuildFeatures, Permissions, Fonts } from "../../../Constants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import { useStateFromStoresObject } from "../../../_bundle/Module589";
|
|
import useEmbeddedAppsForChannel from "../../activities/useEmbeddedAppsForChannel";
|
|
import { useOptInEnabledForGuild } from "../../opt_in_channels/isOptInEnabled";
|
|
import { useUnreadThreadsCountForParent } from "../../forums/ForumHooks";
|
|
import showChannelBadge from "../showChannelBadge";
|
|
import ChannelBadge from "./ChannelBadge";
|
|
import { hasStream } from "../ChannelListUtils";
|
|
import { LiveTag } from "../../../design/void/native";
|
|
import { showChannelItemEmbeddedActivities } from "../showChannelItemEmbeddedActivities";
|
|
import ChannelItemEmbeddedActivities from "./ChannelItemEmbeddedActivities";
|
|
import GuildRoleSubscriptionGatedChannelIcon from "../../guild_role_subscriptions/native/premium_channel/GuildRoleSubscriptionGatedChannelIcon";
|
|
import { getStageHasMedia } from "../../stage_channels/StageMediaHooks";
|
|
import useShowConnectedUserLimit from "../useShowConnectedUserLimit";
|
|
import { ConnectedUserLimit } from "./ConnectedUserLimit";
|
|
import { useStartTime } from "../../channel/useVoiceChannelStartTime";
|
|
import { ActiveTimestamp } from "../../icymi/native/content_inventory/Badges";
|
|
let useStyles, DurationInfo;
|
|
const LimitAndDurationInfo = function LimitAndDurationInfo(props) {
|
|
let r29;
|
|
const { channel, voiceStatesCount, selected } = props;
|
|
const stateFromStoresObject = useStateFromStoresObject([VoiceStateStore, PermissionStore], () => {
|
|
const hasVideo = VoiceStateStore.hasVideo(channel.id);
|
|
const hasMedia = channel.isGuildStageVoice() && getStageHasMedia(channel.id);
|
|
return {
|
|
isLocked: !PermissionStore.can(Permissions.CONNECT, channel),
|
|
hasVideo,
|
|
hasMedia
|
|
};
|
|
});
|
|
const isLocked = stateFromStoresObject.isLocked;
|
|
let hasVideo = stateFromStoresObject.hasVideo;
|
|
const hasMedia = stateFromStoresObject.hasMedia;
|
|
if (useShowConnectedUserLimit({
|
|
channel,
|
|
locked: isLocked,
|
|
video: hasVideo ? hasVideo : hasMedia,
|
|
selected
|
|
})) {
|
|
if (!hasVideo) {
|
|
hasVideo = hasMedia;
|
|
}
|
|
r29 = <ConnectedUserLimit userCount={voiceStatesCount} video={hasVideo} channel={channel} />;
|
|
} else {
|
|
r29 = <DurationInfo channel={channel} />;
|
|
}
|
|
return r29;
|
|
};
|
|
DurationInfo = function DurationInfo(props) {
|
|
const channel3 = props.channel;
|
|
const styles = useStyles();
|
|
const startTime = useStartTime(channel3);
|
|
return startTime != null ? <ActiveTimestamp entry={{
|
|
start: startTime
|
|
}} style={styles.activeTimestamp} /> : null;
|
|
};
|
|
useStyles = createStyles({
|
|
activeTimestamp: {
|
|
fontFamily: Fonts.CODE_NORMAL,
|
|
fontSize: 12,
|
|
lineHeight: 16
|
|
}
|
|
});
|
|
export default function ChannelInfo(props) {
|
|
let r64;
|
|
let channel2;
|
|
L32: {
|
|
channel2 = props.channel;
|
|
const { isChannelSelected, isChannelCollapsed, voiceStates, enableConnectedUserLimit, enableActivities, muted, isSubscriptionGated, needSubscriptionToAccess } = props;
|
|
const stateFromStoresObject = useStateFromStoresObject([GuildStore, ReadStateStore, NewChannelsStore], () => ({
|
|
guild: GuildStore.getGuild(channel2.guild_id),
|
|
mentionsCount: ReadStateStore.getMentionCount(channel2.id),
|
|
isMentionLowImportance: ReadStateStore.getIsMentionLowImportance(channel2.id),
|
|
isNewChannel: NewChannelsStore.shouldIndicateNewChannel(channel2.guild_id, channel2.id)
|
|
}));
|
|
const { guild, mentionsCount, isMentionLowImportance } = stateFromStoresObject;
|
|
let isNewChannel = stateFromStoresObject.isNewChannel;
|
|
const embeddedAppsForChannel = useEmbeddedAppsForChannel(channel2);
|
|
const optInEnabledForGuild = useOptInEnabledForGuild(channel2.guild_id);
|
|
const unreadThreadsCountForParent = useUnreadThreadsCountForParent(channel2.guild_id, channel2.id);
|
|
if (showChannelBadge({
|
|
mentionsCount,
|
|
isNewChannel,
|
|
postsWithUnreadsCount: unreadThreadsCountForParent,
|
|
muted
|
|
})) {
|
|
if (isNewChannel) {
|
|
isNewChannel = optInEnabledForGuild;
|
|
}
|
|
r64 = <ChannelBadge mentionCount={mentionsCount} isMentionLowImportance={isMentionLowImportance} isNewChannel={isNewChannel} postsWithUnreadsCount={channel2.isForumLikeChannel() ? unreadThreadsCountForParent : null} muted={muted} />;
|
|
} else {
|
|
if (isChannelCollapsed != null && isChannelCollapsed && (guild == null ? void 0 : guild.features.has(GuildFeatures.COMMUNITY)) && hasStream(voiceStates)) {
|
|
r64 = <LiveTag />;
|
|
break L32;
|
|
}
|
|
if (enableActivities != null && enableActivities && showChannelItemEmbeddedActivities(embeddedAppsForChannel)) {
|
|
r64 = <ChannelItemEmbeddedActivities embeddedApps={embeddedAppsForChannel} muted={muted} />;
|
|
break L32;
|
|
}
|
|
if (isSubscriptionGated != null && needSubscriptionToAccess != null && isSubscriptionGated) {
|
|
r64 = <GuildRoleSubscriptionGatedChannelIcon locked={needSubscriptionToAccess} />;
|
|
break L32;
|
|
}
|
|
const r63 = enableConnectedUserLimit != null;
|
|
r64 = null;
|
|
if (r63) {
|
|
r64 = null;
|
|
if (enableConnectedUserLimit) {
|
|
let voiceStatesCount = voiceStates?.length;
|
|
if (voiceStatesCount == null) {
|
|
voiceStatesCount = 0;
|
|
}
|
|
r64 = <LimitAndDurationInfo channel={channel2} voiceStatesCount={voiceStatesCount} selected={isChannelSelected} />;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return r64;
|
|
};
|