53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
// Metro module 9773 (f9774).
|
|
import _slicedToArray from "../../_bundle/_slicedToArray";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
let c6480_1 = {
|
|
sentGifts: {}
|
|
};
|
|
class SentGiftsStore extends Module589.PersistedStore {
|
|
static displayName = "SentGiftsStore";
|
|
static persistKey = "SentGiftsStore";
|
|
initialize(a0) {
|
|
if (a0 != null) {
|
|
c6480_1 = a0;
|
|
this.cleanupExpiredGifts();
|
|
}
|
|
}
|
|
getState() {
|
|
return c6480_1;
|
|
}
|
|
hasSentGift(a0, a1) {
|
|
const r17 = c6480_1.sentGifts[`${a0}:${a1}`];
|
|
return r17 != null && !(new Date(r17.expiresAt) < new Date());
|
|
}
|
|
getSentGift(a0, a1) {
|
|
const r17 = c6480_1.sentGifts[`${a0}:${a1}`];
|
|
return r17 == null ? null : new Date(r17.expiresAt) < new Date() ? null : r17;
|
|
}
|
|
cleanupExpiredGifts() {
|
|
const date = new Date();
|
|
for (const item of Object.entries(c6480_1.sentGifts)) {
|
|
const r34 = _slicedToArray(item, 2);
|
|
const r35 = r34[0];
|
|
if (new Date(r34[1].expiresAt) < date) {
|
|
delete c6480_1.sentGifts[r35];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const sentGiftsStore = new SentGiftsStore(Dispatcher, {
|
|
WISHLIST_GIFT_SENT: function handleGiftSent(a0) {
|
|
const r14 = `${a0.skuId}:${a0.recipientId}`;
|
|
const date = new Date();
|
|
const date2 = new Date(date.getTime() + 172800000);
|
|
c6480_1.sentGifts[r14] = {
|
|
skuId: a0.skuId,
|
|
recipientId: a0.recipientId,
|
|
sentAt: date.toISOString(),
|
|
expiresAt: date2.toISOString()
|
|
};
|
|
}
|
|
});
|
|
export default sentGiftsStore;
|