55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
// Metro module 16123 (f16124).
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
|
|
import SelectedGuildStore from "../../../stores/SelectedGuildStore";
|
|
import { AgeGateSource, EXISTING_USER_AGE_GATE_MODAL_KEY } from "../AgeGateConstants";
|
|
import { ChannelTypes, GuildNSFWContentLevel } from "../../../Constants";
|
|
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
|
|
import { maybeShowAgeGate } from "../AgeGateUtils";
|
|
import ModalActionCreators from "../../../actions/ModalActionCreators";
|
|
import { ModalAnimation } from "../../../ConstantsIOS";
|
|
class AgeGateManager extends AutomaticLifecycleManager {
|
|
actions = {
|
|
POST_CONNECTION_OPEN: this.handlePostConnectionOpen,
|
|
CHANNEL_SELECT: this.handleChannelSelect,
|
|
AGE_GATE_MODAL_OPEN: this.handleAgeGateModalOpen,
|
|
AGE_GATE_MODAL_CLOSE: this.handleAgeGateModalClose,
|
|
GUILD_UPDATE: this.handleGuildUpdate
|
|
};
|
|
handlePostConnectionOpen() {
|
|
maybeShowAgeGate(SelectedGuildStore.getGuildId(), SelectedChannelStore.getChannelId());
|
|
}
|
|
handleChannelSelect({ guildId, channelId }) {
|
|
const channel = ChannelStore.getChannel(channelId);
|
|
if (guildId != null && channel?.type !== ChannelTypes.GUILD_VOICE) {
|
|
maybeShowAgeGate(guildId, channelId);
|
|
}
|
|
}
|
|
handleAgeGateModalOpen({ source }) {
|
|
ModalActionCreators.pushLazy(async () => {
|
|
let c28229_1;
|
|
c28229_1 = void 0;
|
|
let c30954_0 = (await import("./components/ExistingUserAgeGateModal")).default;
|
|
if (source === AgeGateSource.AUTH) {
|
|
c30954_0.modalConfig = {
|
|
animation: ModalAnimation.SLIDE_IN_OUT
|
|
};
|
|
}
|
|
return c30954_0;
|
|
}, {
|
|
source
|
|
}, EXISTING_USER_AGE_GATE_MODAL_KEY);
|
|
}
|
|
handleAgeGateModalClose() {
|
|
ModalActionCreators.popWithKey(EXISTING_USER_AGE_GATE_MODAL_KEY);
|
|
}
|
|
handleGuildUpdate({ guild }) {
|
|
const guildId = SelectedGuildStore.getGuildId();
|
|
if (guildId != null && guild.id === guildId && guild.owner_configured_content_level === GuildNSFWContentLevel.AGE_RESTRICTED) {
|
|
maybeShowAgeGate(guild.id, null);
|
|
}
|
|
}
|
|
}
|
|
const ageGateManager = new AgeGateManager();
|
|
export default ageGateManager;
|