decord/source/modules/midjourney_onboarding/MidjourneyOnboardingUtils.tsx

119 lines
3.8 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 13377
// Function ID: 13378
2026-07-20 16:05:17 +00:00
// Name: isMidjourneyOnboardingFlow
2026-08-24 06:08:38 +00:00
// Dependencies: [1910, 4201, 13378, 589, 2]
2026-07-29 08:29:29 +00:00
// Exports: hasRedirectedToGuild, isEligibleForMidjourneyRedirect, isMidjourneyOnboardingFlow, useIsMidjourneyOnboardingFlow
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 13377 (isMidjourneyOnboardingFlow)
import initialize from "initialize" /* 589 */;
import closure_2 from "createGuildRecordFromRust" /* 1910 */;
import closure_3 from "handleConnectionOpen" /* 4201 */;
import MIDJOURNEY_GUILD_ID from "MIDJOURNEY_GUILD_ID" /* 13378 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-29 08:29:29 +00:00
({ MIDJOURNEY_BOT_ID: c4, MIDJOURNEY_GUILD_ID: c5 } = MIDJOURNEY_GUILD_ID);
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/midjourney_onboarding/MidjourneyOnboardingUtils.tsx");
2026-07-29 08:29:29 +00:00
export const isMidjourneyOnboardingFlow = function isMidjourneyOnboardingFlow() {
2026-07-20 16:05:17 +00:00
let obj = arg0;
if (arg0 === undefined) {
obj = {};
}
let guildStore = obj.guildStore;
2026-07-29 08:29:29 +00:00
if (guildStore == null) {
2026-08-24 06:08:38 +00:00
guildStore = closure_2;
2026-07-20 16:05:17 +00:00
}
const guild = guildStore.getGuild(closure_5);
let joinedAt;
2026-07-29 08:29:29 +00:00
if (guild != null) {
2026-07-20 16:05:17 +00:00
joinedAt = guild.joinedAt;
}
let tmp3 = joinedAt instanceof Date;
if (tmp3) {
const _Date = Date;
joinedAt = guild.joinedAt;
const timestamp = Date.now();
tmp3 = timestamp - joinedAt.getTime() <= 3600000;
}
return 1 === guildStore.getGuildCount() && tmp3;
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export const useIsMidjourneyOnboardingFlow = function useIsMidjourneyOnboardingFlow() {
2026-08-24 06:08:38 +00:00
const items = [closure_2];
return initialize.useStateFromStores(items, () => {
let guildStore = { guildStore: closure_2 }.guildStore;
2026-07-29 08:29:29 +00:00
if (guildStore == null) {
2026-08-24 06:08:38 +00:00
guildStore = closure_2;
2026-07-29 08:29:29 +00:00
}
const guild = guildStore.getGuild(closure_5);
let joinedAt;
if (guild != null) {
joinedAt = guild.joinedAt;
}
let tmp3 = joinedAt instanceof Date;
if (tmp3) {
const _Date = Date;
joinedAt = guild.joinedAt;
const timestamp = Date.now();
tmp3 = timestamp - joinedAt.getTime() <= 3600000;
}
return 1 === guildStore.getGuildCount() && tmp3;
}, []);
2026-07-20 16:05:17 +00:00
};
2026-08-24 06:08:38 +00:00
export const isEligibleForMidjourneyRedirect = function isEligibleForMidjourneyRedirect(closure_1_0) {
let isDMResult = closure_1_0.isDM();
2026-07-20 16:05:17 +00:00
if (isDMResult) {
2026-08-24 06:08:38 +00:00
isDMResult = 1 === closure_1_0.rawRecipients.length;
2026-07-20 16:05:17 +00:00
}
if (isDMResult) {
2026-08-24 06:08:38 +00:00
isDMResult = closure_1_0.rawRecipients[0].id === closure_4;
2026-07-20 16:05:17 +00:00
}
if (isDMResult) {
2026-07-29 08:29:29 +00:00
let guildStore = {}.guildStore;
if (guildStore == null) {
2026-08-24 06:08:38 +00:00
guildStore = closure_2;
2026-07-29 08:29:29 +00:00
}
const guild = guildStore.getGuild(closure_5);
let joinedAt;
if (guild != null) {
joinedAt = guild.joinedAt;
}
const _Date = Date;
let tmp8 = joinedAt instanceof Date;
if (tmp8) {
const _Date2 = Date;
joinedAt = guild.joinedAt;
const timestamp = Date.now();
tmp8 = timestamp - joinedAt.getTime() <= 3600000;
}
isDMResult = 1 === guildStore.getGuildCount() && tmp8;
const tmp10 = 1 === guildStore.getGuildCount() && tmp8;
2026-07-20 16:05:17 +00:00
}
return isDMResult;
};
2026-08-24 06:08:38 +00:00
export const hasRedirectedToGuild = function hasRedirectedToGuild(closure_1_4) {
closure_0 = closure_1_4;
2026-07-20 16:05:17 +00:00
return new Promise((arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
2026-07-20 16:05:17 +00:00
function handleSelectedGuildUpdate() {
2026-08-24 06:08:38 +00:00
if (closure_2_3.getGuildId() === callback) {
closure_2_3.removeChangeListener(handleSelectedGuildUpdate);
2026-07-29 08:29:29 +00:00
const _clearTimeout = clearTimeout;
2026-08-24 06:08:38 +00:00
clearTimeout(closure_2);
2026-07-23 10:11:24 +00:00
callback();
2026-07-20 16:05:17 +00:00
}
}
2026-08-24 06:08:38 +00:00
if (closure_1_3.getGuildId() !== closure_0) {
2026-07-20 16:05:17 +00:00
const _setTimeout = setTimeout;
const timeout = setTimeout(() => {
2026-08-24 06:08:38 +00:00
closure_2_3.removeChangeListener(handleSelectedGuildUpdate);
clearTimeout(closure_2);
2026-07-23 10:11:24 +00:00
callback2();
2026-07-20 16:05:17 +00:00
}, 3000);
2026-08-24 06:08:38 +00:00
closure_1_3.addChangeListener(handleSelectedGuildUpdate);
2026-07-20 16:05:17 +00:00
} else {
arg0();
}
});
};