82 lines
2.7 KiB
TypeScript
82 lines
2.7 KiB
TypeScript
// Metro module 13554 (f13555).
|
|
import ApplicationStore from "../modules/applications/ApplicationStore";
|
|
import SKUStore from "../stores/game_store/SKUStore";
|
|
import StoreListingStore from "../stores/game_store/StoreListingStore";
|
|
import { Endpoints } from "../Constants";
|
|
import { httpGetWithCountryCodeQuery } from "../utils/StoreUtils";
|
|
import { rejectWithMigratedError } from "../_bundle/sendRequest";
|
|
import Dispatcher from "../Dispatcher";
|
|
import * as _TestModeUtils from "../modules/game_store/TestModeUtils";
|
|
export function fetchStoreListingsForApplications(a0) {
|
|
const application_ids = a0.filter((item) => {
|
|
const application = ApplicationStore.getApplication(item);
|
|
if (application == null) {
|
|
return true;
|
|
}
|
|
const destinationSkuId = application.destinationSkuId;
|
|
return destinationSkuId == null || StoreListingStore.getForSKU(destinationSkuId) == null;
|
|
});
|
|
return application_ids.length === 0 ? Promise.resolve() : httpGetWithCountryCodeQuery({
|
|
url: Endpoints.STORE_PUBLISHED_LISTINGS_APPLICATIONS,
|
|
query: {
|
|
application_ids
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
}).then((result) => {
|
|
Dispatcher.dispatch({
|
|
type: "STORE_LISTINGS_FETCH_SUCCESS",
|
|
storeListings: result.body
|
|
});
|
|
});
|
|
}
|
|
export function fetchAllStoreListingsForApplication(a0) {
|
|
return httpGetWithCountryCodeQuery({
|
|
url: Endpoints.STORE_PUBLISHED_LISTINGS_SKUS,
|
|
query: {
|
|
application_id: a0
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
}).then((result) => {
|
|
Dispatcher.dispatch({
|
|
type: "STORE_LISTINGS_FETCH_SUCCESS",
|
|
storeListings: result.body.map((item) => ({
|
|
...item,
|
|
published: true
|
|
}))
|
|
});
|
|
return result.body;
|
|
});
|
|
}
|
|
export function fetchStoreListingForSku(a0) {
|
|
const skuId = a0;
|
|
const r10 = SKUStore.get(a0);
|
|
const isTestModeForApplication = r10 != null && _TestModeUtils.isTestModeForApplication(r10.applicationId);
|
|
Dispatcher.dispatch({
|
|
type: "STORE_LISTINGS_FETCH_START",
|
|
skuId: a0
|
|
});
|
|
return httpGetWithCountryCodeQuery({
|
|
url: isTestModeForApplication ? Endpoints.STORE_LISTINGS_SKU(a0) : Endpoints.STORE_PUBLISHED_LISTINGS_SKU(a0),
|
|
rejectWithError: rejectWithMigratedError()
|
|
}).then((result) => {
|
|
if (isTestModeForApplication) {
|
|
Dispatcher.dispatch({
|
|
type: "STORE_LISTINGS_FETCH_SUCCESS",
|
|
storeListings: result.body
|
|
});
|
|
} else {
|
|
Dispatcher.dispatch({
|
|
type: "STORE_LISTING_FETCH_SUCCESS",
|
|
storeListing: result.body
|
|
});
|
|
}
|
|
}).catch(() => {
|
|
Dispatcher.dispatch({
|
|
type: "SKU_FETCH_FAIL",
|
|
skuId
|
|
});
|
|
});
|
|
}
|