143 lines
4.4 KiB
TypeScript
143 lines
4.4 KiB
TypeScript
// Metro module 11580 (f11581).
|
|
import { GUILD_POWERUP_APPLICATION_ID, GuildPowerupType } from "./constants/GuildPowerupsConstants";
|
|
import { Endpoints } from "../../../Constants";
|
|
import Dispatcher from "../../../Dispatcher";
|
|
import { MOCK_LEVELS, MOCK_PERKS } from "./mocks/GuildPowerupMocks";
|
|
import { httpGetWithCountryCodeQuery } from "../../../utils/StoreUtils";
|
|
import { rejectWithMigratedError, HTTP } from "../../../_bundle/sendRequest";
|
|
import storeListingToGuildPowerup from "./utils/storeListingToGuildPowerup";
|
|
import { isNotNullish } from "../../../utils/GlobalUtils";
|
|
export function guildPowerupsAckNotification(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_POWERUPS_ACK_NOTIFICATION",
|
|
guildId: a0
|
|
});
|
|
}
|
|
export function guildPowerupsResetNotifications() {
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_POWERUPS_RESET_NOTIFICATIONS"
|
|
});
|
|
}
|
|
export function fetchPowerupCatalogForGuild(a0, a1) {
|
|
const guildId = a0;
|
|
if (a1 === true) {
|
|
const r34 = MOCK_LEVELS.concat(MOCK_PERKS);
|
|
const powerupCatalog = {};
|
|
powerupCatalog[GuildPowerupType.LEVEL] = MOCK_LEVELS;
|
|
powerupCatalog[GuildPowerupType.PERK] = MOCK_PERKS;
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_POWERUP_CATALOG_FETCH_SUCCESS",
|
|
guildId: a0,
|
|
allPowerups: r34.sort((a, b) => a.skuId >= b.skuId ? 1 : -1).reduce((acc, item) => {
|
|
acc[item.skuId] = item;
|
|
return acc;
|
|
}, {}),
|
|
powerupCatalog
|
|
});
|
|
return void 0;
|
|
}
|
|
return httpGetWithCountryCodeQuery({
|
|
url: Endpoints.STORE_PUBLISHED_LISTINGS_SKUS,
|
|
query: {
|
|
application_id: GUILD_POWERUP_APPLICATION_ID,
|
|
guild_id: a0
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
}).then((result) => {
|
|
const r23 = result.body.map((item) => storeListingToGuildPowerup(result.body, item)).filter(isNotNullish).sort((a, b) => a.skuId >= b.skuId ? 1 : -1).reduce((acc, item) => {
|
|
const { allPowerups, powerupCatalog } = acc;
|
|
allPowerups[item.skuId] = item;
|
|
if (powerupCatalog[item.type] == null) {
|
|
powerupCatalog[item.type] = [];
|
|
}
|
|
const r11 = powerupCatalog[item.type];
|
|
if (r11 != null) {
|
|
const push = r11.push;
|
|
if (push != null) {
|
|
push.call(r11, item);
|
|
}
|
|
}
|
|
return acc;
|
|
}, {
|
|
allPowerups: {},
|
|
powerupCatalog: {}
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_POWERUP_CATALOG_FETCH_SUCCESS",
|
|
guildId,
|
|
allPowerups: r23.allPowerups,
|
|
powerupCatalog: r23.powerupCatalog
|
|
});
|
|
return result.body;
|
|
});
|
|
}
|
|
export function fetchGuildBoostEntitlements(a0) {
|
|
const guildId2 = a0;
|
|
let include_ends_at = arguments[1];
|
|
if (include_ends_at === void 0) {
|
|
include_ends_at = true;
|
|
}
|
|
return httpGetWithCountryCodeQuery({
|
|
url: Endpoints.GUILD_POWERUPS(a0),
|
|
query: {
|
|
include_ends_at
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
}).then((result) => {
|
|
const unlockedPowerups = {};
|
|
let c27112_0 = unlockedPowerups;
|
|
const unlockedGameServers = {};
|
|
let c27112_1 = unlockedGameServers;
|
|
result.body.forEach((item) => {
|
|
const sku = item.sku;
|
|
const r2 = sku == null;
|
|
let r4 = void 0;
|
|
if (!r2) {
|
|
const tenant_metadata = sku.tenant_metadata;
|
|
r4 = tenant_metadata == null ? void 0 : tenant_metadata.guild_monetization?.powerup;
|
|
}
|
|
L16: {
|
|
if (r4 == null) {
|
|
if ((item == null ? void 0 : item.sku?.powerup_metadata) == null) {
|
|
const sku2 = item.sku;
|
|
const r16 = sku2 == null;
|
|
let r17 = void 0;
|
|
if (!r16) {
|
|
const tenant_metadata2 = sku2.tenant_metadata;
|
|
r17 = tenant_metadata2 == null ? void 0 : tenant_metadata2.guild_monetization?.game_server;
|
|
}
|
|
if (r17 == null) {
|
|
break L16;
|
|
}
|
|
c27112_1[item.id] = item;
|
|
} else {
|
|
c27112_0[item.sku_id] = item;
|
|
}
|
|
} else {
|
|
c27112_0[item.sku_id] = item;
|
|
}
|
|
}
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_BOOST_ENTITLEMENTS_FETCH_SUCCESS",
|
|
guildId: guildId2,
|
|
unlockedPowerups,
|
|
unlockedGameServers
|
|
});
|
|
});
|
|
}
|
|
export function enablePowerupForGuild(a0, a1) {
|
|
return HTTP.post({
|
|
url: Endpoints.GUILD_POWERUP_TOGGLE(a0, a1),
|
|
rejectWithError: true
|
|
});
|
|
}
|
|
export function disablePowerupForGuild(a0, a1) {
|
|
return HTTP.del({
|
|
url: Endpoints.GUILD_POWERUP_TOGGLE(a0, a1),
|
|
rejectWithError: true
|
|
});
|
|
}
|