190 lines
6.8 KiB
TypeScript
190 lines
6.8 KiB
TypeScript
// Metro module 14978 (f14979).
|
|
import { useMemo } from "react";
|
|
import { View } from "react-native";
|
|
import GuildChannelStore, { GUILD_VOCAL_CHANNELS_KEY } from "../../../stores/GuildChannelStore";
|
|
import RelationshipStore from "../../../stores/RelationshipStore";
|
|
import UserGuildSettingsStore from "../../../stores/UserGuildSettingsStore";
|
|
import SortedVoiceStateStore from "../../../stores/views/SortedVoiceStateStore";
|
|
import { ChannelTypes } from "../../../Constants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { AvatarPile } from "../../../design/components/Pile/native/AvatarPile.native";
|
|
import { AvatarSizes, Avatar } from "../../../design/void/native";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import useFetchStreamPreview from "../../go_live/useFetchStreamPreview";
|
|
import FastImage from "../../../components_native/common/FastImage";
|
|
import Module4611 from "../../../_bundle/Module4611";
|
|
import { useIsHomeDrawerChannelInChannelList } from "./isHomeDrawerChannelInChannelList";
|
|
import { useStateFromStoresArray, useStateFromStores } from "../../../_bundle/Module589";
|
|
import Module12 from "../../../_bundle/Module12";
|
|
import { filterOutBlockedOrIgnoredUsers } from "../../blocking/BlockedUserUtils";
|
|
let useStyles, useStyles2, LiveTag;
|
|
const VoiceUsers = function VoiceUsers(props) {
|
|
const { voiceUsers, guildId } = props;
|
|
const r11 = voiceUsers.length > 3 ? voiceUsers.slice(0, 3) : voiceUsers;
|
|
return voiceUsers.length !== 0 ? <View style={{
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: 4
|
|
}}>
|
|
<AvatarPile size={AvatarSizes.XSMALL} names={r11.map((item) => item.username)} totalCount={r11.length}>
|
|
{r11.map((item) => <Avatar key={item.id} size={AvatarSizes.XSMALL} user={item} guildId={guildId} animate={false} />)}
|
|
</AvatarPile>
|
|
</View> : null;
|
|
};
|
|
LiveTag = function LiveTag() {
|
|
const styles2 = useStyles2();
|
|
return <View style={styles2.tag}>
|
|
<Text variant="text-xxs/bold" style={styles2.tagText} lineClamp={1}>
|
|
{intl.string(t.dI3q4h).toUpperCase()}
|
|
</Text>
|
|
</View>;
|
|
};
|
|
useStyles = createStyles({
|
|
voiceContainer: {
|
|
paddingRight: 8,
|
|
height: 40,
|
|
gap: 4,
|
|
justifyContent: "center"
|
|
},
|
|
streamPreviewShadow: {
|
|
borderRadius: Module712.radii.sm,
|
|
...Module712.shadows.SHADOW_MEDIUM
|
|
},
|
|
streamPreview: {
|
|
width: 72,
|
|
height: 44,
|
|
borderRadius: Module712.radii.sm,
|
|
overflow: "hidden"
|
|
},
|
|
streamPreviewDarkGradient: {
|
|
position: "absolute",
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
opacity: 0.8
|
|
},
|
|
streamPreviewGradient: {
|
|
position: "absolute",
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
opacity: 0.2
|
|
},
|
|
streamPreviewBorder: {
|
|
position: "absolute",
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
borderWidth: 1,
|
|
borderColor: Module712.colors.BORDER_SUBTLE,
|
|
borderRadius: Module712.radii.sm
|
|
}
|
|
});
|
|
useStyles2 = createStyles({
|
|
tag: {
|
|
paddingHorizontal: 4,
|
|
paddingVertical: 1,
|
|
borderBottomRightRadius: Module712.radii.xs,
|
|
overflow: "hidden",
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
backgroundColor: Module712.unsafe_rawColors.RED_400,
|
|
position: "absolute",
|
|
top: 0,
|
|
left: 0
|
|
},
|
|
tagText: {
|
|
textAlign: "center",
|
|
color: Module712.unsafe_rawColors.WHITE,
|
|
includeFontPadding: false
|
|
}
|
|
});
|
|
export function GuildVoiceState(props) {
|
|
const voiceUsers = props.voiceUsers;
|
|
let streamingChannelId2 = props.streamingChannelId;
|
|
const { streamingUser, guildId: guildId2 } = props;
|
|
const styles = useStyles();
|
|
const r4 = voiceUsers.length > 0;
|
|
if (streamingChannelId2 == null) {
|
|
streamingChannelId2 = void 0;
|
|
}
|
|
const previewUrl = useFetchStreamPreview(guildId2, streamingChannelId2, streamingUser?.id).previewUrl;
|
|
return r4 ? <View style={[styles.voiceContainer, {
|
|
height: streamingUser != null ? 48 : 32
|
|
}]}>
|
|
{previewUrl == null ? <VoiceUsers voiceUsers={voiceUsers} guildId={guildId2} /> : <View style={styles.streamPreviewShadow}>
|
|
<View style={styles.streamPreview}>
|
|
<FastImage style={styles.streamPreview} source={{
|
|
uri: previewUrl
|
|
}} />
|
|
<Module4611 colors={["rgba(0, 0, 0, 1)", "rgba(0, 0, 0, 0)"]} start={{
|
|
x: 0,
|
|
y: 0
|
|
}} end={{
|
|
x: 0,
|
|
y: 1
|
|
}} style={styles.streamPreviewDarkGradient} pointerEvents="none" />
|
|
<Module4611 colors={["rgba(255, 255, 255, 1)", "rgba(255, 255, 255, 0)"]} start={{
|
|
x: 0,
|
|
y: 0
|
|
}} end={{
|
|
x: 1,
|
|
y: 1
|
|
}} style={styles.streamPreviewGradient} pointerEvents="none" />
|
|
<View style={styles.streamPreviewBorder} pointerEvents="none" />
|
|
<LiveTag />
|
|
</View>
|
|
</View>}
|
|
</View> : null;
|
|
}
|
|
export function useVoiceUsers(a0) {
|
|
let stateFromStores, stateFromStoresArray2;
|
|
let c21498_0 = a0;
|
|
const id = a0.id;
|
|
const isHomeDrawerChannelInChannelList = useIsHomeDrawerChannelInChannelList();
|
|
const stateFromStoresArray = useStateFromStoresArray([GuildChannelStore, UserGuildSettingsStore], () => GuildChannelStore.getChannels(id)[GUILD_VOCAL_CHANNELS_KEY].filter(({ channel }) => channel.type === ChannelTypes.GUILD_VOICE && !UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(id, channel.id) && isHomeDrawerChannelInChannelList(channel)).map((item) => item.channel.id), [id, isHomeDrawerChannelInChannelList]);
|
|
stateFromStores = useStateFromStores([SortedVoiceStateStore], () => SortedVoiceStateStore.getVoiceStates(id), [id]);
|
|
stateFromStoresArray2 = useStateFromStoresArray([RelationshipStore], () => RelationshipStore.getBlockedOrIgnoredIDs());
|
|
const memo = useMemo(() => Module12.flatMap(stateFromStoresArray, (a0) => {
|
|
if (a0 === c21498_0.afkChannelId) {
|
|
return [];
|
|
}
|
|
let r4 = stateFromStores[a0];
|
|
if (r4 == null) {
|
|
r4 = [];
|
|
}
|
|
return filterOutBlockedOrIgnoredUsers(r4.map((item) => item.user), stateFromStoresArray2);
|
|
}), [stateFromStoresArray, stateFromStores, a0.afkChannelId, stateFromStoresArray2]);
|
|
const memo2 = useMemo(() => {
|
|
const user = null;
|
|
let streamingChannelId = null;
|
|
Object.keys(stateFromStores).forEach((a0) => {
|
|
if (a0 !== c21498_0.afkChannelId && stateFromStoresArray.includes(a0)) {
|
|
let r6 = stateFromStores[a0];
|
|
if (r6 == null) {
|
|
r6 = [];
|
|
}
|
|
const r14 = r6.find((item) => item.voiceState.selfStream);
|
|
if (r14 != null && user == null) {
|
|
user = r14.user;
|
|
streamingChannelId = a0;
|
|
}
|
|
}
|
|
});
|
|
return {
|
|
streamingUser: user,
|
|
streamingChannelId
|
|
};
|
|
}, [stateFromStores, a0.afkChannelId, stateFromStoresArray]);
|
|
return {
|
|
voiceUsers: memo,
|
|
streamingUser: memo2.streamingUser,
|
|
streamingChannelId: memo2.streamingChannelId
|
|
};
|
|
}
|