222 lines
6.0 KiB
TypeScript
222 lines
6.0 KiB
TypeScript
// Metro module 8674 (f8675).
|
|
import WishlistRecord, { getWishlistSkuIds, wishlistHasSkuId } from "./records/WishlistRecord";
|
|
import SentryUtils_native from "../../utils/SentryUtils.native";
|
|
import * as _UserProfileStore from "../user_profile/UserProfileStore";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
let c5649_6 = {};
|
|
class WishlistStore extends Module589.Store {
|
|
get(a0) {
|
|
let r4 = c5649_6[a0];
|
|
if (r4 == null) {
|
|
r4 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
}
|
|
return r4;
|
|
}
|
|
getWishlist(a0) {
|
|
return this.get(a0).data;
|
|
}
|
|
getWishlistItems(a0) {
|
|
const data = this.get(a0).data;
|
|
return data != null ? getWishlistSkuIds(data) : [];
|
|
}
|
|
hasSkuId(a0, a1) {
|
|
const data = this.get(a0).data;
|
|
return data != null && wishlistHasSkuId(data, a1);
|
|
}
|
|
getStatus(a0) {
|
|
return this.get(a0).status;
|
|
}
|
|
isFetching(a0) {
|
|
return this.getStatus(a0) === "fetching";
|
|
}
|
|
hasError(a0) {
|
|
return this.getStatus(a0) === "error";
|
|
}
|
|
getError(a0) {
|
|
return this.get(a0).error;
|
|
}
|
|
getUpdatedAt(a0) {
|
|
return this.get(a0).updatedAt;
|
|
}
|
|
getLastFetchedAt(a0) {
|
|
return this.get(a0).lastFetchedAt;
|
|
}
|
|
}
|
|
const wishlistStore = new WishlistStore(Dispatcher, {
|
|
WISHLIST_FETCH_START: function handleFetchStart({ wishlistId }) {
|
|
let r6 = c5649_6[wishlistId];
|
|
if (r6 == null) {
|
|
const r2 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r2;
|
|
r6 = r2;
|
|
}
|
|
r6.status = "fetching";
|
|
r6.error = void 0;
|
|
},
|
|
WISHLIST_FETCH_SUCCESS: function handleFetchSuccess({ wishlistId, wishlistData, updatedAt }) {
|
|
let r8 = c5649_6[wishlistId];
|
|
if (r8 == null) {
|
|
const r4 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r4;
|
|
r8 = r4;
|
|
}
|
|
r8.data = wishlistData;
|
|
r8.status = "success";
|
|
r8.error = void 0;
|
|
r8.updatedAt = updatedAt;
|
|
r8.lastFetchedAt = Date.now();
|
|
},
|
|
WISHLIST_FETCH_FAILURE: function handleFetchFailure({ wishlistId, error }) {
|
|
let r7 = c5649_6[wishlistId];
|
|
if (r7 == null) {
|
|
const r3 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r3;
|
|
r7 = r3;
|
|
}
|
|
r7.status = "error";
|
|
r7.error = error;
|
|
},
|
|
WISHLIST_ADD_SKU_SUCCESS: function handleAddSkuSuccess({ wishlistId, wishlistData }) {
|
|
let r7 = c5649_6[wishlistId];
|
|
if (r7 == null) {
|
|
const r3 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r3;
|
|
r7 = r3;
|
|
}
|
|
r7.data = wishlistData;
|
|
r7.status = "success";
|
|
r7.error = void 0;
|
|
r7.lastFetchedAt = Date.now();
|
|
},
|
|
WISHLIST_ADD_SKU_FAILURE: function handleAddSkuFailure(a0) {
|
|
SentryUtils_native.captureException(a0.error);
|
|
},
|
|
WISHLIST_REMOVE_SKU_START: function handleRemoveSkuStart({ wishlistId, skuId }) {
|
|
let r10 = c5649_6[wishlistId];
|
|
if (r10 == null) {
|
|
const r4 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r4;
|
|
r10 = r4;
|
|
}
|
|
if (r10.data != null) {
|
|
r10.data = new WishlistRecord({
|
|
id: r10.data.id,
|
|
userId: r10.data.userId,
|
|
items: r10.data.items.filter((item) => item.skuId !== skuId),
|
|
applications: r10.data.applications
|
|
});
|
|
}
|
|
},
|
|
WISHLIST_REMOVE_SKU_SUCCESS: function handleRemoveSkuSuccess({ wishlistId, wishlistData }) {
|
|
let r7 = c5649_6[wishlistId];
|
|
if (r7 == null) {
|
|
const r3 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r3;
|
|
r7 = r3;
|
|
}
|
|
r7.data = wishlistData;
|
|
r7.status = "success";
|
|
r7.error = void 0;
|
|
r7.lastFetchedAt = Date.now();
|
|
},
|
|
WISHLIST_REMOVE_SKU_FAILURE: function handleRemoveSkuFailure({ wishlistId, error }) {
|
|
let r7 = c5649_6[wishlistId];
|
|
if (r7 == null) {
|
|
const r4 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r4;
|
|
r7 = r4;
|
|
}
|
|
r7.updatedAt = void 0;
|
|
SentryUtils_native.captureException(error);
|
|
},
|
|
WISHLIST_UPDATE_VISIBILITY_SUCCESS: function handleUpdateVisibilitySuccess({ wishlistId }) {
|
|
let r2 = c5649_6[wishlistId];
|
|
if (r2 == null) {
|
|
const r6 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r6;
|
|
r2 = r6;
|
|
}
|
|
r2.status = "success";
|
|
r2.error = void 0;
|
|
r2.lastFetchedAt = Date.now();
|
|
},
|
|
WISHLIST_UPDATE_VISIBILITY_FAILURE: function handleUpdateVisibilityFailure(a0) {
|
|
SentryUtils_native.captureException(a0.error);
|
|
},
|
|
WISHLIST_REORDER_START: function handleReorderStart({ wishlistId, newWishlistData }) {
|
|
let r7 = c5649_6[wishlistId];
|
|
if (r7 == null) {
|
|
const r3 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r3;
|
|
r7 = r3;
|
|
}
|
|
r7.data = newWishlistData;
|
|
},
|
|
WISHLIST_REORDER_SUCCESS: function handleReorderSuccess({ wishlistId, wishlistData }) {
|
|
let r7 = c5649_6[wishlistId];
|
|
if (r7 == null) {
|
|
const r3 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r3;
|
|
r7 = r3;
|
|
}
|
|
r7.data = wishlistData;
|
|
r7.status = "success";
|
|
r7.error = void 0;
|
|
r7.lastFetchedAt = Date.now();
|
|
},
|
|
WISHLIST_REORDER_FAILURE: function handleReorderFailure({ wishlistId, error }) {
|
|
let r7 = c5649_6[wishlistId];
|
|
if (r7 == null) {
|
|
const r4 = {
|
|
data: null,
|
|
status: "not_loaded"
|
|
};
|
|
c5649_6[wishlistId] = r4;
|
|
r7 = r4;
|
|
}
|
|
r7.updatedAt = void 0;
|
|
SentryUtils_native.captureException(error);
|
|
},
|
|
WISHLIST_ITEM_PURCHASED: function handleWishlistItemPurchased({ recipientId, skuId: skuId2 }) {
|
|
const firstWishlistId = _UserProfileStore.default.getFirstWishlistId(recipientId);
|
|
if (firstWishlistId != null && c5649_6[firstWishlistId] != null && c5649_6[firstWishlistId].data != null && wishlistHasSkuId(c5649_6[firstWishlistId].data, skuId2)) {
|
|
c5649_6[firstWishlistId].updatedAt = void 0;
|
|
}
|
|
}
|
|
});
|
|
export default wishlistStore;
|