260 lines
7.3 KiB
TypeScript
260 lines
7.3 KiB
TypeScript
// Metro module 13552 (f13553).
|
|
import { SKUTypes, SKUProductLines } from "../../Constants";
|
|
import Dispatcher from "../../Dispatcher";
|
|
import { getSubscriptionGroupForSubscriptionPlan, getApplicationSubscriptionGroupListingsForApplication, getEntitlementsForGuild } from "./ApplicationSubscriptionsHttpApi";
|
|
import { fetchSubscriptionPlansForSKU } from "../../actions/SubscriptionPlanActionCreators";
|
|
function $mk116545($env) {
|
|
return (a0) => {
|
|
if (a0.subscription_plans[0].id === $env[0]) {
|
|
return fetchSubscriptionPlansForSKU(a0.id, void 0, void 0, true);
|
|
}
|
|
};
|
|
}
|
|
let transformSubscriptionListingToStoreListing, dispatchCompat, fetchSubscriptionListingForPlan;
|
|
let env9411 = {};
|
|
const transformSubscriptionListingToSku = function transformSubscriptionListingToSku(a0) {
|
|
return {
|
|
id: a0.id,
|
|
type: SKUTypes.SUBSCRIPTION,
|
|
application_id: a0.application_id,
|
|
product_line: SKUProductLines.APPLICATION,
|
|
name: a0.name,
|
|
summary: "",
|
|
description: a0.description,
|
|
flags: a0.sku_flags,
|
|
manifests: [],
|
|
available_regions: [],
|
|
legal_notice: "",
|
|
deleted: a0.soft_deleted,
|
|
price_tier: 0,
|
|
show_age_gate: false,
|
|
restricted: false
|
|
};
|
|
};
|
|
transformSubscriptionListingToStoreListing = function transformSubscriptionListingToStoreListing(a0) {
|
|
let store_listing_benefits = a0.store_listing_benefits;
|
|
if (store_listing_benefits == null) {
|
|
store_listing_benefits = [];
|
|
}
|
|
return {
|
|
id: a0.id,
|
|
sku: {
|
|
id: a0.id,
|
|
type: SKUTypes.SUBSCRIPTION,
|
|
application_id: a0.application_id,
|
|
product_line: SKUProductLines.APPLICATION,
|
|
name: a0.name,
|
|
summary: "",
|
|
description: a0.description,
|
|
flags: a0.sku_flags,
|
|
manifests: [],
|
|
available_regions: [],
|
|
legal_notice: "",
|
|
deleted: a0.soft_deleted,
|
|
price_tier: 0,
|
|
show_age_gate: false,
|
|
restricted: false
|
|
},
|
|
summary: a0.description,
|
|
description: a0.description,
|
|
benefits: store_listing_benefits,
|
|
thumbnail: a0.image_asset,
|
|
published: a0.published
|
|
};
|
|
};
|
|
dispatchCompat = function dispatchCompat(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "SKUS_FETCH_SUCCESS",
|
|
skus: a0.map(transformSubscriptionListingToSku)
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "STORE_LISTINGS_FETCH_SUCCESS",
|
|
storeListings: a0.map(transformSubscriptionListingToStoreListing)
|
|
});
|
|
for (const item of a0) {
|
|
Dispatcher.dispatch({
|
|
type: "SUBSCRIPTION_PLANS_FETCH_SUCCESS",
|
|
skuId: item.id,
|
|
subscriptionPlans: item.subscription_plans
|
|
});
|
|
}
|
|
};
|
|
fetchSubscriptionListingForPlan = async function fetchSubscriptionListingForPlan(c27509_0, c27509_1) {
|
|
let subscription_listings2, c27509_3, c27509_4, c27509_5;
|
|
let c27509_6 = 0;
|
|
const r17 = env9411;
|
|
try {
|
|
let env30644;
|
|
c27509_4 = r17;
|
|
const r40 = env30644 = {
|
|
$parent: r17
|
|
};
|
|
c27509_3 = r40;
|
|
env30644[1] = void 0;
|
|
env30644[0] = c27509_0;
|
|
if (c27509_1 !== void 0) {
|
|
env30644[1] = c27509_1;
|
|
env30644[2] = void 0;
|
|
env30644[3] = void 0;
|
|
} else {
|
|
env30644[1] = 0;
|
|
env30644[2] = void 0;
|
|
env30644[3] = void 0;
|
|
}
|
|
await void 0;
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_SUBSCRIPTIONS_FETCH_LISTING_FOR_PLAN",
|
|
planId: env30644[0]
|
|
});
|
|
c27509_6 = 1;
|
|
env30644[2] = await getSubscriptionGroupForSubscriptionPlan(env30644[0]);
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_SUBSCRIPTIONS_FETCH_LISTING_FOR_PLAN_SUCCESS",
|
|
groupListing: env30644[2]
|
|
});
|
|
const subscription_listings3 = env30644[2].subscription_listings;
|
|
subscription_listings2 = subscription_listings3;
|
|
if (subscription_listings3 == null) {
|
|
subscription_listings2 = [];
|
|
}
|
|
const r116 = c27509_3;
|
|
env30644[3] = subscription_listings2;
|
|
await Promise.all(env30644[3].map($mk116545(r116)));
|
|
(0, dispatchCompat)(env30644[3]);
|
|
c27509_6 = 0;
|
|
} catch ($e) {
|
|
const r38 = $e;
|
|
let r8 = r38;
|
|
c27509_5 = r38;
|
|
if (c27509_6 !== 0) {
|
|
while (true) {
|
|
L32: {
|
|
try {
|
|
const r160 = c27509_5;
|
|
c27509_6 = 0;
|
|
env30644[4] = r160;
|
|
if ("status" in env30644[4] && env30644[4].status === 429 && env30644[1] < 10) {
|
|
const r174 = env30644[0];
|
|
const r176 = env30644[1] + 1;
|
|
env30644[1] = r176;
|
|
await fetchSubscriptionListingForPlan(r174, r176);
|
|
break L32;
|
|
}
|
|
throw env30644[4];
|
|
} catch (r157) {
|
|
r8 = r157;
|
|
c27509_5 = r157;
|
|
if (c27509_6 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
};
|
|
export async function fetchAllSubscriptionListingsDataForApplication(applicationId, groupListingId) {
|
|
let r73;
|
|
let subscription_listings;
|
|
let c27507_6 = 0;
|
|
let c30642_0, c30642_1;
|
|
try {
|
|
c30642_0 = applicationId;
|
|
c30642_1 = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_SUBSCRIPTIONS_FETCH_LISTINGS",
|
|
applicationId,
|
|
groupListingId
|
|
});
|
|
c27507_6 = 1;
|
|
c30642_1 = await getApplicationSubscriptionGroupListingsForApplication(applicationId, groupListingId);
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_SUBSCRIPTIONS_FETCH_LISTINGS_SUCCESS",
|
|
applicationId: c30642_0,
|
|
groupListing: c30642_1
|
|
});
|
|
const subscription_listings3 = c30642_1.subscription_listings;
|
|
subscription_listings = subscription_listings3;
|
|
if (subscription_listings3 == null) {
|
|
subscription_listings = [];
|
|
}
|
|
dispatchCompat(subscription_listings);
|
|
r73 = c30642_1;
|
|
c27507_6 = 0;
|
|
} catch ($e) {
|
|
let r8 = $e;
|
|
if (c27507_6 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c27507_6 = 0;
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_SUBSCRIPTIONS_FETCH_LISTINGS_FAILURE",
|
|
applicationId: c30642_0
|
|
});
|
|
} catch ($e) {
|
|
r8 = $e;
|
|
if (c27507_6 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r73;
|
|
}
|
|
export async function fetchEntitlementsForGuild(guildId) {
|
|
let c27508_4 = 0;
|
|
let c30643_0, c30643_1;
|
|
L10: {
|
|
try {
|
|
c30643_0 = guildId;
|
|
c30643_1 = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_SUBSCRIPTIONS_FETCH_ENTITLEMENTS",
|
|
guildId
|
|
});
|
|
c27508_4 = 1;
|
|
c30643_1 = await getEntitlementsForGuild(guildId);
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_SUBSCRIPTIONS_FETCH_ENTITLEMENTS_SUCCESS",
|
|
guildId: c30643_0,
|
|
entitlements: c30643_1
|
|
});
|
|
c27508_4 = 0;
|
|
} catch ($e) {
|
|
let r8 = $e;
|
|
if (c27508_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c27508_4 = 0;
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_SUBSCRIPTIONS_FETCH_ENTITLEMENTS_FAILURE",
|
|
guildId: c30643_0
|
|
});
|
|
break L10;
|
|
} catch ($e) {
|
|
r8 = $e;
|
|
if (c27508_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
}
|
|
export function dismissApplicationSubscriptionExpirationNotice(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_SUBSCRIPTIONS_CHANNEL_NOTICE_DISMISSED",
|
|
guildId: a0
|
|
});
|
|
}
|
|
export { fetchSubscriptionListingForPlan };
|