285 lines
8.4 KiB
TypeScript
285 lines
8.4 KiB
TypeScript
// Metro module 6689 (f6690).
|
|
import LurkingStore from "../modules/lurker_mode/LurkingStore";
|
|
import GuildMemberCountStore from "../stores/GuildMemberCountStore";
|
|
import GuildStore from "../stores/GuildStore";
|
|
import { AnalyticEvents, Endpoints, Routes, SearchTypes } from "../Constants";
|
|
import { getHistory } from "../modules/routing/router_utils";
|
|
import { transitionToGuild } from "../modules/routing/transitionToGuild.native";
|
|
import safeTransitionTo_native from "../modules/links/safeTransitionTo.native";
|
|
import GuildActionCreators from "../actions/GuildActionCreators";
|
|
import { getMobileLurkerServerPreview } from "../modules/lurker_mode/experiments/MobileLurkerServerPreviewExperiment";
|
|
import { trackLurkStarted } from "../modules/lurker_mode/LurkerPreviewAnalytics";
|
|
import AnalyticsUtils from "./AnalyticsUtils";
|
|
import { HTTP } from "../_bundle/sendRequest";
|
|
import Module1464 from "../_bundle/Module1464";
|
|
const makeDiscoverableGuild = function makeDiscoverableGuild(a0) {
|
|
return {
|
|
id: a0.id,
|
|
name: a0.name,
|
|
description: a0.description,
|
|
splash: a0.splash,
|
|
banner: a0.banner,
|
|
icon: a0.icon,
|
|
features: new Set(a0.features),
|
|
presenceCount: a0.approximate_presence_count,
|
|
memberCount: a0.approximate_member_count,
|
|
premiumSubscriptionCount: a0.premium_subscription_count,
|
|
preferredLocale: a0.preferred_locale,
|
|
discoverySplash: a0.discovery_splash,
|
|
emojis: a0.emojis,
|
|
emojiCount: a0.emoji_count,
|
|
stickers: a0.stickers,
|
|
stickerCount: a0.sticker_count,
|
|
keywords: a0.keywords
|
|
};
|
|
};
|
|
const r30 = {
|
|
SEARCH: "Search",
|
|
RECOMMENDED: "Recommended",
|
|
POPULAR: "Popular",
|
|
RECOMMENDED_E3: "Recommended - E3",
|
|
HEADER: "Header",
|
|
GLOBAL_DISCOVERY: "Global Discovery",
|
|
FORWARD_BREADCRUMB: "Forward Breadcrumb"
|
|
};
|
|
export { r30 as AnalyticsContexts };
|
|
export const IOS_MINIMUM_MEMBER_COUNT = ">1000";
|
|
export const MINIMUM_MEMBER_COUNT = ">200";
|
|
export async function startLurking(c25956_0, c25956_1, c25956_2, c25956_3) {
|
|
let page, c25956_6;
|
|
let c29820_9, c29820_10, c29820_11, c29820_12, c29820_13;
|
|
c25956_6 = void 0;
|
|
let c29820_0 = c25956_0;
|
|
let c29820_1 = c25956_1;
|
|
let r39 = c25956_2;
|
|
if (r39 === void 0) {
|
|
r39 = {};
|
|
}
|
|
let c29820_2 = r39;
|
|
let c29820_3 = c25956_3;
|
|
c29820_9 = void 0;
|
|
c29820_10 = void 0;
|
|
c29820_11 = void 0;
|
|
c29820_12 = void 0;
|
|
c29820_13 = void 0;
|
|
await void 0;
|
|
let c29820_4 = c29820_2.channelId;
|
|
let c29820_5 = c29820_2.onSuccess;
|
|
let c29820_6 = c29820_2.joinSource;
|
|
let c29820_7 = c29820_2.loadId;
|
|
let c29820_8 = c29820_2.shouldNavigate;
|
|
const r12 = c29820_8 === void 0 || c29820_8;
|
|
L16: {
|
|
c29820_9 = r12;
|
|
c29820_10 = getHistory();
|
|
c29820_11 = GuildStore.getGuild(c29820_0);
|
|
c29820_12 = {
|
|
sourceLocationStack: c29820_3,
|
|
state: {
|
|
analyticsSource: c29820_1
|
|
}
|
|
};
|
|
if (c29820_11 != null && c29820_11.joinedAt != null) {
|
|
if (!c29820_9) {
|
|
break L16;
|
|
}
|
|
if (c29820_4 == null) {
|
|
transitionToGuild(c29820_0, c29820_12);
|
|
break L16;
|
|
}
|
|
safeTransitionTo_native(Routes.CHANNEL(c29820_0, c29820_4, c29820_2.messageId), {
|
|
...c29820_12,
|
|
navigationReplace: true,
|
|
openChannel: true
|
|
});
|
|
} else {
|
|
if (c29820_11 != null && LurkingStore.isLurking(c29820_0)) {
|
|
if (!c29820_9) {
|
|
break L16;
|
|
}
|
|
await GuildActionCreators.transitionToGuildSync(c29820_0, {
|
|
...c29820_12,
|
|
welcomeModalChannelId: c29820_4,
|
|
navigationReplace: c29820_4 != null,
|
|
openChannel: c29820_4 != null,
|
|
search: c29820_10.location.search
|
|
}, c29820_4, c29820_2.messageId);
|
|
break L16;
|
|
}
|
|
page = c29820_3 == null ? void 0 : c29820_3[c29820_3.length - 1];
|
|
if (page == null) {
|
|
page = c29820_1?.page;
|
|
}
|
|
c29820_13 = page;
|
|
if (getMobileLurkerServerPreview("startLurking").enabled) {
|
|
trackLurkStarted(c29820_0, c29820_6, c29820_13);
|
|
}
|
|
await GuildActionCreators.joinGuild(c29820_0, {
|
|
lurker: true,
|
|
source: c29820_6,
|
|
loadId: c29820_7,
|
|
lurkLocation: c29820_13
|
|
});
|
|
if (c29820_9) {
|
|
await GuildActionCreators.transitionToGuildSync(c29820_0, {
|
|
...c29820_12,
|
|
welcomeModalChannelId: c29820_4,
|
|
navigationReplace: c29820_4 != null,
|
|
openChannel: c29820_4 != null,
|
|
search: c29820_10.location.search
|
|
}, c29820_4, c29820_2.messageId);
|
|
}
|
|
}
|
|
}
|
|
if (c29820_5 != null) {
|
|
c29820_5();
|
|
}
|
|
}
|
|
export { makeDiscoverableGuild };
|
|
export function trackDiscoveryExited(a0, a1, recommendations_source = null) {
|
|
AnalyticsUtils.track(AnalyticEvents.GUILD_DISCOVERY_EXITED, {
|
|
load_id: a0,
|
|
guild_ids_viewed: a1,
|
|
recommendations_source
|
|
});
|
|
}
|
|
export function trackSearchClosed(a0) {
|
|
AnalyticsUtils.track(AnalyticEvents.SEARCH_CLOSED, {
|
|
load_id: a0
|
|
});
|
|
}
|
|
export function trackSearchStarted(a0, a1, r6 = {}) {
|
|
AnalyticsUtils.track(AnalyticEvents.SEARCH_STARTED, {
|
|
search_type: SearchTypes.GUILD_DISCOVERY,
|
|
load_id: a0,
|
|
location: r6.location,
|
|
category_id: a1
|
|
});
|
|
}
|
|
export function trackGuildDiscoverySearchStart(a0) {
|
|
AnalyticsUtils.track(AnalyticEvents.GUILD_DISCOVERY_SEARCH_START, {
|
|
with_counts: a0.withCounts,
|
|
offset: a0.offset
|
|
});
|
|
}
|
|
export function trackSearchFailed(a0) {
|
|
const { categoryId, error } = a0;
|
|
AnalyticsUtils.track(AnalyticEvents.GUILD_DISCOVERY_SEARCH_FAILED, {
|
|
category_id: categoryId,
|
|
request_status: error.status,
|
|
request_error_code: error.code,
|
|
will_request_retry: a0.willRequestRetry,
|
|
is_request_retry: a0.isRequestRetry
|
|
});
|
|
}
|
|
export function trackGuildDiscoveryGetFeaturedGuildsFailed(a0) {
|
|
AnalyticsUtils.track(AnalyticEvents.GUILD_DISCOVERY_GET_FEATURED_GUILDS_FAILED, {
|
|
category_id: a0.categoryId
|
|
});
|
|
}
|
|
export function trackSearchResultsViewed({ loadId, searchId, query, guildResults, analyticsContext, categoryId, isTagSearch }) {
|
|
const SEARCH_RESULT_VIEWED = AnalyticEvents.SEARCH_RESULT_VIEWED;
|
|
const search_type = isTagSearch ? SearchTypes.GUILD_DISCOVERY_TAG : SearchTypes.GUILD_DISCOVERY;
|
|
const r1 = guildResults !== void 0;
|
|
AnalyticsUtils.track(SEARCH_RESULT_VIEWED, {
|
|
search_type,
|
|
load_id: loadId,
|
|
search_id: searchId,
|
|
total_results: r1 ? guildResults.length : null,
|
|
guild_ids: r1 ? guildResults.map((guildResult) => guildResult.id) : null,
|
|
query,
|
|
location: analyticsContext.location,
|
|
category_id: categoryId
|
|
});
|
|
}
|
|
export function trackGuildJoinClicked(a0) {
|
|
AnalyticsUtils.track(AnalyticEvents.GUILD_DISCOVERY_GUILD_JOIN_CLICKED, {
|
|
guild_id: a0,
|
|
load_id: LurkingStore.getLoadId(a0),
|
|
guild_size: GuildMemberCountStore.getMemberCount(a0)
|
|
});
|
|
}
|
|
export async function getDiscoverableGuild(guild_ids) {
|
|
let r67;
|
|
let c25957_4 = 0;
|
|
let c29821_0, c29821_1;
|
|
try {
|
|
c29821_0 = void 0;
|
|
c29821_1 = void 0;
|
|
c25957_4 = 1;
|
|
c29821_0 = await HTTP.get({
|
|
url: Endpoints.GUILD_DISCOVERY,
|
|
query: Module1464.stringify({
|
|
guild_ids
|
|
}),
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
});
|
|
const body = c29821_0.body;
|
|
const r60 = body == null;
|
|
let r61 = void 0;
|
|
if (!r60) {
|
|
const guilds = body.guilds;
|
|
r61 = guilds == null ? void 0 : guilds[0];
|
|
}
|
|
c29821_1 = r61;
|
|
r67 = c29821_1 == null ? c29821_1 : (0, makeDiscoverableGuild)(c29821_1);
|
|
c25957_4 = 0;
|
|
} catch ($e) {
|
|
let r8 = $e;
|
|
if (c25957_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c25957_4 = 0;
|
|
} catch ($e) {
|
|
r8 = $e;
|
|
if (c25957_4 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r67;
|
|
}
|
|
export async function fetchPublicDiscoveryGuild(c25958_0) {
|
|
let r61;
|
|
let c25958_3 = 0;
|
|
let c29822_0;
|
|
try {
|
|
c29822_0 = void 0;
|
|
c25958_3 = 1;
|
|
c29822_0 = (await HTTP.get({
|
|
url: Endpoints.GUILD_DISCOVERY_SLUG(String(c25958_0)),
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
})).body;
|
|
r61 = c29822_0?.guild == null ? null : c29822_0?.slug == null ? null : {
|
|
guild: c29822_0.guild,
|
|
slug: c29822_0.slug
|
|
};
|
|
c25958_3 = 0;
|
|
} catch ($e) {
|
|
let r27 = $e;
|
|
if (c25958_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c25958_3 = 0;
|
|
} catch ($e) {
|
|
r27 = $e;
|
|
if (c25958_3 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
throw r27;
|
|
}
|
|
return r61;
|
|
}
|