85 lines
4.3 KiB
TypeScript
85 lines
4.3 KiB
TypeScript
// Metro module 14999 (f15000).
|
|
import * as Module19 from "react";
|
|
import { useMemo } from "react";
|
|
import AuthenticationStore from "../../../stores/AuthenticationStore";
|
|
import CallStore from "../../../stores/CallStore";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildReadStateStore from "../../../stores/GuildReadStateStore";
|
|
import RelationshipStore from "../../../stores/RelationshipStore";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import { ChannelTypes } from "../../../Constants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import GuildsBarAnimatedItemWrapper, { useGuildsBarAnimatedWrapperStyles } from "./GuildsBarAnimatedItemWrapper";
|
|
import { useStateFromStores, useStateFromStoresObject } from "../../../_bundle/Module589";
|
|
import getChannelA11yLabel from "../../channel/getChannelA11yLabel";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import useGuildsBarBottomRightBadge from "./hooks/useGuildsBarBottomRightBadge";
|
|
import { transitionToChannel } from "../../routing/transitionToChannel";
|
|
import { openChannelLongPressActionSheet } from "../../channel/native/openChannelLongPressActionSheet";
|
|
import HomeDrawerDM from "../../home_drawer/native/HomeDrawerDM";
|
|
import GroupDMAvatar from "../../group_dm/native/GroupDMAvatar";
|
|
import { AvatarSizes } from "../../../design/void/native";
|
|
import FastImage from "../../../components_native/common/FastImage";
|
|
const useStyles = createStyles({
|
|
dm: {
|
|
width: Module712.modules.mobile.GUILD_BAR_ITEM_SIZE,
|
|
height: Module712.modules.mobile.GUILD_BAR_ITEM_SIZE
|
|
}
|
|
});
|
|
const r51 = Module19.memo(function GuildsBarDirectMessage(props) {
|
|
let channel, dmRecipient;
|
|
const channelId = props.channelId;
|
|
channel = void 0;
|
|
dmRecipient = void 0;
|
|
const styles = useStyles();
|
|
const styles2 = useGuildsBarAnimatedWrapperStyles({
|
|
disableSelectedColor: true,
|
|
disableBGColor: true
|
|
});
|
|
const stateFromStores = useStateFromStores([GuildReadStateStore], () => GuildReadStateStore.getMentionCountForPrivateChannel(channelId).count);
|
|
const stateFromStoresObject = useStateFromStoresObject([ChannelStore, UserStore, RelationshipStore, CallStore, AuthenticationStore], () => {
|
|
const channel2 = ChannelStore.getChannel(channelId);
|
|
const dmRecipient2 = channel2?.type === ChannelTypes.DM ? UserStore.getUser(channel2.getRecipientId()) : void 0;
|
|
const call = CallStore.getCall(channelId);
|
|
const id = AuthenticationStore.getId();
|
|
const isIncomingCall = call != null && id != null && call.ringing.includes(id);
|
|
const isOngoingCall = CallStore.isCallActive(channelId) && !isIncomingCall;
|
|
return {
|
|
channel: channel2,
|
|
dmRecipient: dmRecipient2,
|
|
label: channel2 != null ? getChannelA11yLabel({
|
|
channel: channel2,
|
|
unread: stateFromStores > 0,
|
|
mentionCount: stateFromStores,
|
|
isIncomingCall,
|
|
isOngoingCall
|
|
}) : intl.string(t.zLZPmk)
|
|
};
|
|
});
|
|
channel = stateFromStoresObject.channel;
|
|
dmRecipient = stateFromStoresObject.dmRecipient;
|
|
const label = stateFromStoresObject.label;
|
|
const guildsBarBottomRightBadge = useGuildsBarBottomRightBadge({
|
|
mentionCount: stateFromStores
|
|
});
|
|
const { badge, cutouts } = guildsBarBottomRightBadge;
|
|
const memo = useMemo(() => (channel == null ? void 0 : channel.isDM()) ? dmRecipient == null ? void 0 : dmRecipient.getAvatarSource(void 0) : void 0, [channel, dmRecipient]);
|
|
const memo2 = useMemo(() => ({
|
|
onPress: () => {
|
|
if (channel != null) {
|
|
transitionToChannel(channel.id);
|
|
}
|
|
},
|
|
onLongPress: () => {
|
|
if (channel != null) {
|
|
openChannelLongPressActionSheet(channel.id);
|
|
}
|
|
}
|
|
}), [channel]);
|
|
return <GuildsBarAnimatedItemWrapper selected={false} circle={!(channel == null ? void 0 : channel.isMultiUserDM())} unread styles={styles2} label={label} overState={void 0} config={memo2} cutouts={cutouts} externalChildren={badge} expandedChildren={channel != null ? <HomeDrawerDM channel={channel} /> : null}>
|
|
{(channel == null ? void 0 : channel.isMultiUserDM()) ? <GroupDMAvatar channel={channel} size={AvatarSizes.LARGE_48} pileSizeOverride={AvatarSizes.REFRESH_MEDIUM_32} animate /> : memo != null ? <FastImage style={styles.dm} source={memo} /> : null}
|
|
</GuildsBarAnimatedItemWrapper>;
|
|
});
|
|
export default r51;
|