99 lines
4.5 KiB
TypeScript
99 lines
4.5 KiB
TypeScript
// Metro module 16191 (f16192).
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import PermissionStore from "../../../stores/PermissionStore";
|
|
import SelectedGuildStore from "../../../stores/SelectedGuildStore";
|
|
import GuildPowerupsStore from "./GuildPowerupsStore";
|
|
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
|
|
import { isFavoritesGuildId } from "../../favorites/FavoritesUtils";
|
|
import { GameServerExperiment, getGameServerEnabled } from "../game_server/GameServerExperiment";
|
|
import { FileUpload250MbPowerupExperiment } from "./experiments/FileUpload250MbPowerupExperiment";
|
|
import { ServerThemeExperiment, getServerThemeEnabled } from "./experiments/ServerThemeExperiment";
|
|
import { ServerThemeApexShadowExperiment } from "./experiments/ServerThemeApexShadowExperiment";
|
|
import { GameServerPricingExperiment } from "../game_server/experiments/GameServerPricingExperiment";
|
|
import { getHasAllocateBoostPermission } from "./hooks/useHasAllocateBoostPermission";
|
|
import { getIsCurrentUserEligibleForPowerupUpsells } from "./hooks/useIsCurrentUserEligibleForPowerupUpsells";
|
|
import { isMobile } from "../../../_bundle/Module4426";
|
|
import { getServerThemeUserEnabled } from "./experiments/ServerThemeUserExperiment";
|
|
import BoostToUnlockMobileCoachmarkExperiment from "../../guild_boosting/experiments/BoostToUnlockMobileCoachmarkExperiment";
|
|
import { fetchPowerupCatalogForGuild, fetchGuildBoostEntitlements } from "./GuildPowerupsActionCreators";
|
|
import ExpiringBoostsExperiment from "./experiments/ExpiringBoostsExperiment";
|
|
import { fetchAppliedGuildBoostsForGuild } from "../../../actions/BoostingActionCreators";
|
|
class GuildPowerupsManager extends AutomaticLifecycleManager {
|
|
stores = new Map().set(SelectedGuildStore, this.handleSelectedGuildChange);
|
|
actions = {
|
|
GUILD_POWERUP_ENTITLEMENTS_CREATE: this.handleEntitlementUpdate.bind(this),
|
|
GUILD_POWERUP_ENTITLEMENTS_DELETE: this.handleEntitlementUpdate.bind(this),
|
|
GUILD_APPLIED_BOOSTS_UPDATE: this.handleAppliedBoostUpdate.bind(this)
|
|
};
|
|
handleSelectedGuildChange() {
|
|
const guildId = SelectedGuildStore.getGuildId();
|
|
if (guildId != null && !isFavoritesGuildId(guildId)) {
|
|
const guild = GuildStore.getGuild(guildId);
|
|
if (guild != null) {
|
|
GameServerExperiment.trackExposure({
|
|
guildId: guild.id,
|
|
location: "GuildPowerupsManager"
|
|
});
|
|
FileUpload250MbPowerupExperiment.trackExposure({
|
|
guildId: guild.id,
|
|
location: "GuildPowerupsManager"
|
|
});
|
|
ServerThemeExperiment.trackExposure({
|
|
guildId: guild.id,
|
|
location: "GuildPowerupsManager"
|
|
});
|
|
ServerThemeApexShadowExperiment.getConfig({
|
|
guildId: guild.id,
|
|
location: "GuildPowerupsManager"
|
|
});
|
|
if (getGameServerEnabled(guild.id, "GuildPowerupsManager")) {
|
|
GameServerPricingExperiment.trackExposure({
|
|
guildId: guild.id,
|
|
location: "GuildPowerupsManager"
|
|
});
|
|
}
|
|
if (!getHasAllocateBoostPermission(PermissionStore, guild)) {
|
|
let r64 = getIsCurrentUserEligibleForPowerupUpsells();
|
|
let r67 = isMobile && getServerThemeEnabled(guildId, "GuildPowerupsManager") && getIsCurrentUserEligibleForPowerupUpsells() && getServerThemeUserEnabled("GuildPowerupsManager");
|
|
const r79 = isMobile && getIsCurrentUserEligibleForPowerupUpsells() && BoostToUnlockMobileCoachmarkExperiment.getConfig({
|
|
location: "GuildPowerupsManager"
|
|
}).showCoachmark;
|
|
if (isMobile) {
|
|
if (!r67) {
|
|
r67 = r79;
|
|
}
|
|
r64 = r67;
|
|
}
|
|
if (!r64) {
|
|
return void 0;
|
|
}
|
|
}
|
|
if (GuildPowerupsStore.shouldFetchCatalogForGuild(guildId)) {
|
|
fetchPowerupCatalogForGuild(guildId);
|
|
}
|
|
if (GuildPowerupsStore.shouldFetchPowerupsForGuild(guildId)) {
|
|
fetchGuildBoostEntitlements(guildId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
handleEntitlementUpdate(a0) {
|
|
this.refreshGuildPowerups(a0.guildId);
|
|
}
|
|
handleAppliedBoostUpdate(a0) {
|
|
this.refreshGuildPowerups(a0.guildId);
|
|
}
|
|
refreshGuildPowerups(a0) {
|
|
if (getHasAllocateBoostPermission(PermissionStore, GuildStore.getGuild(a0)) === true) {
|
|
fetchGuildBoostEntitlements(a0);
|
|
fetchAppliedGuildBoostsForGuild(a0, {
|
|
includeEnded: ExpiringBoostsExperiment.getConfig({
|
|
location: "GuildPowerupsManager"
|
|
}).enabled
|
|
});
|
|
}
|
|
}
|
|
}
|
|
const guildPowerupsManager = new GuildPowerupsManager();
|
|
export default guildPowerupsManager;
|