76 lines
4.4 KiB
TypeScript
76 lines
4.4 KiB
TypeScript
// Metro module 15183 (f15184).
|
|
import { useContext, useRef, useCallback } from "react";
|
|
import { View } from "react-native";
|
|
import { CHANNEL_MARGIN_VERTICAL } from "../../../channel_list_v2/native/RedesignChannelListConstants";
|
|
import { GuildPowerupNotificationIndicatorType } from "../constants/GuildPowerupsNotification";
|
|
import { CircleErrorIcon } from "../../../../design/components/Icon/native/redesign/generated/CircleErrorIcon";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { Badge } from "../../../../design/void/native";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import useGuildPowerupsCoachmark from "./hooks/useGuildPowerupsCoachmark";
|
|
import { SidebarCoachmarkOverlayContext } from "../../../main_tabs_v2/native/panels/SidebarCoachmarkOverlay.native";
|
|
import { LayerContext } from "../../../../design/components/Layers/native/LayerContext.native";
|
|
import useGuildPowerupsNotifications from "../hooks/useGuildPowerupsNotifications";
|
|
import useGuildPowerupsNewBadge from "../hooks/useGuildPowerupsNewBadge";
|
|
import BaseChannelItem, { ChannelModes, BaseChannelName, BaseChannelIcon } from "../../../guild_sidebar/native/BaseChannelItem";
|
|
import openGuildPowerupsModal from "./utils/openGuildPowerupsModal";
|
|
import AnalyticsLocation from "../../../app_analytics/AnalyticsLocation";
|
|
import { intl } from "../../../../intl/index.native";
|
|
import GuildPowerups_messages from "../GuildPowerups.messages";
|
|
import { BoostTier2Icon } from "../../../../design/components/Icon/native/redesign/generated/BoostTier2Icon";
|
|
import { NewBadge } from "../../../channel_list_v2/native/components/index";
|
|
let useStyles, GuildPowerupsCoachmarkHost, GuildPowerupsCoachmark;
|
|
const GuildPowerupsChannelRowIndicator = function GuildPowerupsChannelRowIndicator(props) {
|
|
const indicator = props.indicator;
|
|
if (indicator == null) {
|
|
return null;
|
|
}
|
|
const type = indicator.type;
|
|
if (GuildPowerupNotificationIndicatorType.WARNING === type) {
|
|
return <CircleErrorIcon color={Module712.colors.STATUS_WARNING} size="sm" />;
|
|
}
|
|
if (GuildPowerupNotificationIndicatorType.UNREAD === type) {
|
|
return <Badge value={indicator.count} isMentionLowImportance />;
|
|
}
|
|
return null;
|
|
};
|
|
GuildPowerupsCoachmarkHost = function GuildPowerupsCoachmarkHost(a0) {
|
|
useGuildPowerupsCoachmark(a0.targetRef, a0.guildId, a0.popout);
|
|
return null;
|
|
};
|
|
GuildPowerupsCoachmark = function GuildPowerupsCoachmark(props) {
|
|
const { targetRef, guildId: guildId2, popout } = props;
|
|
const context = useContext(SidebarCoachmarkOverlayContext);
|
|
const r18 = <GuildPowerupsCoachmarkHost targetRef={targetRef} guildId={guildId2} popout={popout} />;
|
|
return context != null ? <LayerContext.Provider value={context}>{r18}</LayerContext.Provider> : r18;
|
|
};
|
|
useStyles = createStyles({
|
|
container: {
|
|
marginVertical: CHANNEL_MARGIN_VERTICAL,
|
|
marginHorizontal: 8,
|
|
borderRadius: Module712.radii.md
|
|
}
|
|
});
|
|
export default function GuildPowerupsChannelRow(props) {
|
|
const guildId = props.guildId;
|
|
const styles = useStyles();
|
|
const ref = useRef(null);
|
|
const guildPowerupsNotifications = useGuildPowerupsNotifications(guildId);
|
|
const guildPowerupsNewBadge = useGuildPowerupsNewBadge(guildId, guildPowerupsNotifications?.indicator != null || guildPowerupsNotifications?.popout != null);
|
|
const { showNewBadgeOnRow, dismissNewBadgeIfShown } = guildPowerupsNewBadge;
|
|
const unread = guildPowerupsNotifications?.showUnread === true;
|
|
const mode = unread ? ChannelModes.UNREAD_IMPORTANT : ChannelModes.DEFAULT;
|
|
return <View ref={ref} collapsable={false}>
|
|
<GuildPowerupsCoachmark targetRef={ref} guildId={guildId} popout={guildPowerupsNotifications?.popout} />
|
|
<BaseChannelItem onPress={useCallback(() => {
|
|
dismissNewBadgeIfShown();
|
|
openGuildPowerupsModal({
|
|
guildId,
|
|
analyticsLocation: AnalyticsLocation.GUILD_POWERUPS_CHANNEL_LIST_ROW
|
|
});
|
|
}, [guildId, dismissNewBadgeIfShown])} style={styles.container} accessible mode={mode} unread={unread} accessibilityLabel={intl.string(GuildPowerups_messages.yv3DJJ)} accessibilityState={{
|
|
selected: false
|
|
}} name={<BaseChannelName name={intl.string(GuildPowerups_messages.yv3DJJ)} mode={mode} />} icon={<BaseChannelIcon mode={mode} IconComponent={BoostTier2Icon} />} channelInfo={showNewBadgeOnRow ? <NewBadge /> : <GuildPowerupsChannelRowIndicator indicator={guildPowerupsNotifications?.indicator} />} />
|
|
</View>;
|
|
};
|