Files
discord-decomp/modules/wishlists/WishlistRecommendationsStore.tsx
T
2026-11-01 12:12:55 +02:00

92 lines
2.6 KiB
TypeScript

// Metro module 9750 (f9751).
import LocaleStore from "../user_settings/LocaleStore";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let locale, c6460_2;
const handleUserSettingsStoreUpdate = function handleUserSettingsStoreUpdate() {
if (locale === LocaleStore.locale) {
return false;
}
c6460_2 = {};
locale = LocaleStore.locale;
};
c6460_2 = {};
class WishlistRecommendationsStore extends Module589.Store {
initialize() {
this.waitFor(LocaleStore);
this.syncWith([LocaleStore], handleUserSettingsStoreUpdate);
locale = LocaleStore.locale;
}
getRecommendations(a0, a1) {
if (a0.length !== 0 && a1.length !== 0) {
if (a0.length === 0) {
throw new Error("No user IDs provided");
}
return c6460_2[[...a0, ...a1].join(",")];
}
}
}
const wishlistRecommendationsStore = new WishlistRecommendationsStore(Dispatcher, {
LOGOUT: function handleLogout() {
c6460_2 = {};
},
WISHLIST_RECOMMENDATIONS_FETCH_START: function handleFetchStart({ userIds, applicationIds }) {
if (userIds.length !== 0 && applicationIds.length !== 0) {
if (userIds.length === 0) {
throw new Error("No user IDs provided");
}
const r20 = [...userIds, ...applicationIds].join(",");
const r21 = {
...c6460_2
};
r21[r20] = {
state: "loading"
};
c6460_2 = r21;
return void 0;
}
return false;
},
WISHLIST_RECOMMENDATIONS_FETCH_SUCCESS: function handleFetchSuccess({ userIds, applicationIds, data }) {
if (userIds.length !== 0 && applicationIds.length !== 0) {
if (userIds.length === 0) {
throw new Error("No user IDs provided");
}
const r22 = [...userIds, ...applicationIds].join(",");
const r23 = {
...c6460_2
};
r23[r22] = {
state: "success",
data,
fetchedAt: Date.now()
};
c6460_2 = r23;
return void 0;
}
return false;
},
WISHLIST_RECOMMENDATIONS_FETCH_FAILURE: function handleFetchFailure({ userIds, applicationIds }) {
if (userIds.length !== 0 && applicationIds.length !== 0) {
if (userIds.length === 0) {
throw new Error("No user IDs provided");
}
const r23 = [...userIds, ...applicationIds].join(",");
if (c6460_2[r23]?.state === "success") {
return false;
}
const r29 = {
...c6460_2
};
r29[r23] = {
state: "error",
fetchedAt: Date.now()
};
c6460_2 = r29;
return void 0;
}
return false;
}
});
export default wishlistRecommendationsStore;