63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
// Metro module 12997 (f12998).
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import SelectedGuildStore from "../../stores/SelectedGuildStore";
|
|
import { MIDJOURNEY_BOT_ID, MIDJOURNEY_GUILD_ID } from "./MidjourneyOnboardingConstants";
|
|
import { useStateFromStores } from "../../_bundle/Module589";
|
|
export function isMidjourneyOnboardingFlow(r4 = {}) {
|
|
let guildStore = r4.guildStore;
|
|
if (guildStore == null) {
|
|
guildStore = GuildStore;
|
|
}
|
|
const guild = guildStore.getGuild(MIDJOURNEY_GUILD_ID);
|
|
const r2 = guild?.joinedAt instanceof Date && Date.now() - guild.joinedAt.getTime() <= 3600000;
|
|
return guildStore.getGuildCount() === 1 && r2;
|
|
}
|
|
export function useIsMidjourneyOnboardingFlow() {
|
|
return useStateFromStores([GuildStore], () => {
|
|
let guildStore = ({
|
|
guildStore: GuildStore
|
|
}).guildStore;
|
|
if (guildStore == null) {
|
|
guildStore = GuildStore;
|
|
}
|
|
const guild = guildStore.getGuild(MIDJOURNEY_GUILD_ID);
|
|
const r2 = guild?.joinedAt instanceof Date && Date.now() - guild.joinedAt.getTime() <= 3600000;
|
|
return guildStore.getGuildCount() === 1 && r2;
|
|
}, []);
|
|
}
|
|
export function isEligibleForMidjourneyRedirect(a0) {
|
|
let r9 = a0.isDM() && a0.rawRecipients.length === 1 && a0.rawRecipients[0].id === MIDJOURNEY_BOT_ID;
|
|
if (r9) {
|
|
let guildStore = ({}).guildStore;
|
|
if (guildStore == null) {
|
|
guildStore = GuildStore;
|
|
}
|
|
const guild = guildStore.getGuild(MIDJOURNEY_GUILD_ID);
|
|
const r2 = guild?.joinedAt instanceof Date && Date.now() - guild.joinedAt.getTime() <= 3600000;
|
|
r9 = guildStore.getGuildCount() === 1 && r2;
|
|
}
|
|
return r9;
|
|
}
|
|
export function hasRedirectedToGuild(c20331_0) {
|
|
return new Promise((resolve, c27391_1) => {
|
|
let c27391_2;
|
|
const handleSelectedGuildUpdate2 = function handleSelectedGuildUpdate() {
|
|
if (SelectedGuildStore.getGuildId() === c20331_0) {
|
|
SelectedGuildStore.removeChangeListener(handleSelectedGuildUpdate2);
|
|
clearTimeout(c27391_2);
|
|
resolve();
|
|
}
|
|
};
|
|
if (SelectedGuildStore.getGuildId() !== c20331_0) {
|
|
c27391_2 = setTimeout(() => {
|
|
SelectedGuildStore.removeChangeListener(handleSelectedGuildUpdate2);
|
|
clearTimeout(c27391_2);
|
|
c27391_1();
|
|
}, 3000);
|
|
SelectedGuildStore.addChangeListener(handleSelectedGuildUpdate2);
|
|
} else {
|
|
resolve();
|
|
}
|
|
});
|
|
}
|