Files
discord-decomp/modules/lurker_mode/openLurkerLeavePrompt.native.tsx
T
2026-11-01 12:12:55 +02:00

88 lines
3.5 KiB
TypeScript

// Metro module 11530 (f11531).
import { useCallback } from "react";
import { StyleSheet, View } from "react-native";
import ChannelStore from "../../stores/ChannelStore";
import GuildStore from "../../stores/GuildStore";
import LurkingStore from "./LurkingStore";
import { JoinGuildSources } from "../../Constants";
import { openAlert } from "../../design/components/AlertModal/native/useAlertStore.native";
import GuildIcon, { GuildIconSizes, ImageSizes } from "../guild/native/GuildIcon";
import { createStyles } from "../../design/components/Styles/native/createStyles";
import { trackLeavePromptLeaveClicked, trackJoinClicked } from "./LurkerPreviewAnalytics";
import { AlertModal, AlertActionButton } from "../../design/components/AlertModal/native/AlertModal.native";
import { intl, t } from "../../intl/index.native";
import GuildBadgeV2 from "../guild/native/GuildBadgeV2";
import { Icon } from "../../design/void/native";
import { setHubProgressActionComplete } from "../hub/HubProgressActionCreators";
import { HubProgressStep } from "../../_bundle/Module1306";
import LurkerPreviewManager from "./LurkerPreviewManager";
import GuildActionCreators from "../../actions/GuildActionCreators";
let c7863_13, useStyles;
const LurkerLeavePromptModal = function LurkerLeavePromptModal(props) {
const { guild, onJoin: onJoin2 } = props;
const styles = useStyles();
const callback = useCallback(() => {
trackLeavePromptLeaveClicked(guild.id);
}, [guild.id]);
return <AlertModal title={guild.name} content={intl.string(t.I1yHxc)} header={<View style={styles.headerRoot}>
<View style={styles.iconWrapper}>
<GuildIcon guild={guild} size={GuildIconSizes.XLARGE} value={guild.name} />
<GuildBadgeV2 guild={guild} size={Icon.Sizes.LARGE} style={StyleSheet.flatten(styles.badgeOverlay)} />
</View>
</View>} actions={<>
<AlertActionButton variant="primary" text={intl.string(t.VJlc0S)} onPress={onJoin2} />
<AlertActionButton variant="secondary" text={intl.string(t["2vl7qn"])} onPress={callback} />
</>} />;
};
c7863_13 = new Set();
const width = ImageSizes[GuildIconSizes.XLARGE];
useStyles = createStyles({
headerRoot: {
alignItems: "center"
},
iconWrapper: {
width,
height: width,
position: "relative"
},
badgeOverlay: {
position: "absolute",
right: -4,
bottom: -4,
marginRight: 0
}
});
export function openLurkerLeavePrompt(a0, a1) {
let c18939_2;
const onLeave = a1.onLeave;
c18939_2 = void 0;
if (!c7863_13.has(a0)) {
const guild2 = GuildStore.getGuild(a0);
if (guild2 != null) {
c7863_13.add(a0);
c18939_2 = false;
openAlert(`lurker-leave-prompt:${a0}`, <LurkerLeavePromptModal guild={guild2} onJoin={() => {
c18939_2 = true;
const lurkingSourceForGuild = LurkingStore.getLurkingSourceForGuild(a0);
if (lurkingSourceForGuild?.type === JoinGuildSources.DIRECTORY_ENTRY) {
const channel = ChannelStore.getChannel(lurkingSourceForGuild.directoryChannelId);
if (channel != null) {
setHubProgressActionComplete(channel.getGuildId(), HubProgressStep.JOIN_GUILD);
}
}
trackJoinClicked(a0, JoinGuildSources.LEAVE_PROMPT_LURKER, LurkerPreviewManager.hasNavigatedAway(a0));
GuildActionCreators.joinGuild(a0, {
source: JoinGuildSources.LEAVE_PROMPT_LURKER
});
}} />, () => {
c7863_13.delete(a0);
if (!c18939_2) {
onLeave();
}
});
} else {
onLeave();
}
}
}